tp5框架index.php入口文件隐藏?

一,找到/public/.htaccess文件,如果你的入口文件已经移动到根目录下,那么你的.htaccess文件也要剪切到根目录下,总之要确保.htaccess跟入口的index.php保持同级。

nginx隐藏indexphp(nginx隐藏php后缀)nginx隐藏indexphp(nginx隐藏php后缀)


nginx隐藏indexphp(nginx隐藏php后缀)


二,根据你的php环境分别设置.htaccess文件:

Apache:

Options +FollowSymlinks -Multiviews

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.)$ [QSA,PT,L]

phpstudy:

Options +FollowSymlinks -Multiviews

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.)$ index.php [L,E=PATH_INFO:$1]

Nginx(在Nginx.conf中添加):

location / { // …..省略部分代码

if (!-e $request_filename) {

rewrite ^(.)$ /index.php?s=/$1 last;

break;

}

}

nginx怎么隐藏index.php

在访问 的时候、跳转到 ;

也就是开启重写功能;

在nginx配置文件nginx.conf中添加:

location / {

if ( !e $request_filename ) {

rewrite ^/(.)$ / last;

}

}

如果项目入口文件是在一个子目录里面,则如下:

location / {

if ( !e $request_filename ) {

rewrite ^/目录/(.)$ /目录/ last;

}

}

切记:不可以出现两个location / {}、否则nginx将启动不了;

我的配置文件如下:

server {

listen 80;

server_name abcphp;

root "D:/abc/php";

location / {

if (!-e $request_filename) {

rewrite ^/(.)$ /index.php?$1 last;

}

index index.html index.htm index.php;

autoindex on;

}

location ~ .php(.)$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_split_path_ ^((?U).+.php)(/?.+)$;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_;

include fastcgi_params;

}

}

其中:

autoindex on; 是打开nginx的浏览目录的功能;

nginx怎么配置隐藏index.php

nginx.conf里边写

location / {

if (!-e $request_filename){

rewrite ^/(.)$ / last;

}

}

nginx配置文件粘贴过来

您好,您可以使用以下配置文件来配置Nginx:

server {

listen 80;

server_name example;

root /var/www/example;

index index.html index.htm;

location / {

try_files $uri $uri/ =404;

}

}

# 开启Gzip压缩

gzip on;

gzip_types text/plain application/x-jascript text/css application/xml;

# 设置缓存

location ~ .(jpg|jpeg|gif|png|css|js|ico|xml)$ {

access_log off;

log_not_found off;

expires 30d;

}

# 设置错误日志

error_log /var/log/nginx/example.error.log;

# 设置访问日志

access_log /var/log/nginx/example.access.log;

nginx隐藏index.php(nginx隐藏php后缀)


Thinkphp3.2.1版本的隐藏index.php怎么弄

可以通过URL重写隐藏应用的入口文件index.php,下面是相关的配置参考:

[ Apache ]

d.conf配置文件中加载了mod_rewrite.so模块

AllowOverride None 将None改为 All

把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.)$ [QSA,PT,L]

[ IIS ]

如果你的环境支持ISAPI_Rewrite的话,可以配置d.ini文件,添加下面的内容:

RewriteRule (.)$ /index.php?s=$1 [I]

在IIS的高版本下面可以配置web.Config,在中间添加rewrite:

[ Nginx ]

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:

location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.)$ /index.php?s=$1 last; break; } }

其实内部是转发到了ThinkPHP提供的兼容模式的URL,利用这种方式,可以解决其他不支持PATHINFO的WEB环境。

如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。

location /youdomain/ { if (!-e $request_filename){ rewrite ^/youdomain/(.)$ /youdomain/index.php?s=$1 last; }}

原来的访问URL:

...]

设置后,我们可以采用下面的方式访问:

...]

默认情况下,URL地址中的模块不能省略,如果你需要简化某个模块的URL访问地址,可以通过设置模块列表和默认模块或者采用子域名部署到模块的方式解决,请参考后面的模块和域名部署部分。