导航:首页 > 编程语言 > nginx隐藏indexphp

nginx隐藏indexphp

发布时间:2022-06-09 00:04:01

Ⅰ 如何去掉index.php目录

apache去掉index.php
1.编辑conf/httpd.conf配置文件
#LoadMole rewrite_mole moles/mod_rewrite.so 把该行前的#去掉
同时对应Directory下要配置 AllowOverride All
2.在 CI 根目录下(即在index.php,system的同级目录下)新建立一个配置文件,命名为: .htaccess 内容如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(application|moles|plugins|system|themes) index.php/$1 [L]
3.把system/application/config/config.php 中$config['index_page'] = "index.php";改为$config['index_page'] = "";
4.重启apache
php CI 实战教程:[9]如何去掉index.php目录
nginx去掉index.php
1.编辑nginx.conf文件
vi /usr/local/xxxxx/nginx/conf/nginx.conf
#nginx去掉index.php
location / {
rewrite ^/$ /index.php last;
#防止某些文件夹被直接访问
rewrite ^/(?!index\.php|robots\.txt|uploadedImages|resource|images|js|css|styles|static)(.*)$ /index.php/$1 last;
}
2.config/config.php下配置$config['index_page'] = '';
3..重启nginx
去掉默认的index方法,如图的URL配置如:
config/routes.php,配置$route['catalogues/(:any)'] = "catalogues/index/$1";
其中(:any)表示匹配所有除CI保留关键字外的内容,后面的$1为index传入的参数内容。
多个参数采用多个(:any),如两个参数的为:$route['catalogues/(:any)/(:any)'] = "catalogues/index/$1/$2";
注:route规则如果同一目录下精确配置要在模糊配置上面,否则不起作用,如:
$route['catalogues/more'] = "catalogues/more";
$route['catalogues/(:any)'] = "catalogues/index/$1";
php CI 实战教程:[9]如何去掉index.php目录
END
注意事项
route规则如果同一目录下精确配置要在模糊配置上面,否则不起作用
nginx服务器不需要.htaccess文件

Ⅱ nginx怎么配置隐藏index.php

nginx.conf里边写

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

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

一,找到/public/.htaccess文件,如果你的入口文件已经移动到根目录下,那么你的.htaccess文件也要剪切到根目录下,总之要确保.htaccess跟入口的index.php保持同级。
二,根据你的php环境分别设置.htaccess文件:
Apache:
<IfMole mod_rewrite.c>Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfMole>

phpstudy:
<IfMole mod_rewrite.c> Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfMole>
Nginx(在Nginx.conf中添加):
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}

Ⅳ nginx怎么配置隐藏入口文件index.php

你用护卫神.nginx大师,设置默认文档不包含index.php就可以了。

Ⅳ Nginx如何配置实现隐藏php后缀

如何实现隐藏php的扩展名访问
提供一个思路: apache可以通过开启mod_rewrite然后重写一下url规则。 nginx的可以通过try_files实现

Ⅵ TPshop商城系统如何在linux下隐藏index.php

系统安装完成之后, 首页访问正常, 除了首页, 任何二级页面都无法访问.

找到nginx配置文件(如果是lnmp一键安装的一般在:/usr/local/nginx/conf 目录下) 找到vhost的conf文件.

在此文件的server下面的内容(此段内容在跟下的nginx.conf2文件中)拷贝到 "root" 后:

TPshop商城系统

Ⅶ 在nginx下如何去除ci框架url中的index.php

apache环境下:
通过 .htaccess 文件来设置一些简单的规则删除它。下面是一个例子,使用“negative”方法将非指定内容进行重定向:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

如果你的项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L]
在上面的例子中,可以实现任何非 index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。

Nginx环境下:
修改nginx配置文件,在SERVER段中添加如下代码:
location /{
if (-f $request_filename) {
expires max;
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}

Ⅷ laravel5.4下nginx怎么把public/index.php隐藏

nginx上配上try_files就好了啊

location/{
try_files$uri$uri//index.php?$args;
}

Ⅸ 宝塔 nginx 隐藏index.php thinkphp

第一步:找到nginx 配置文件

Ⅹ nginx怎么隐藏index.php

在访问 http://php.cc/Att/AttList 的时候、跳转到 http://php.cc/index.php/Att/AttList ;
也就是开启重写功能;
在nginx配置文件nginx.conf中添加:
location / {
if ( !e $request_filename ) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
如果项目入口文件是在一个子目录里面,则如下:
location / {
if ( !e $request_filename ) {
rewrite ^/目录/(.*)$ /目录/index.php/$1 last;
}
}

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

我的配置文件如下:
server {
listen 80;
server_name www.abcphp.cc abcphp.cc;
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_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

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

阅读全文

与nginx隐藏indexphp相关的资料

热点内容
显示当前模式下所有可执行的命令 浏览:758
为什么程序员拿了股份还要高薪 浏览:946
电脑运行命令里的记录能删吗 浏览:697
linuxwss 浏览:848
一个软件需要登录服务器地址 浏览:923
哪里有解压程序 浏览:299
java静态方法内存 浏览:545
我的世界ec服务器如何带vip 浏览:737
什么是由解析器域名和服务器构成 浏览:414
自动识别电影信息源码 浏览:849
柱筋箍筋加密区怎么算 浏览:48
钢筋中加密15倍是什么意思 浏览:366
esc加密算法 浏览:518
linux运行exe命令 浏览:124
一级建造师管理pdf 浏览:720
如何更改服务器登录账号 浏览:317
看pdf文件软件 浏览:183
android恢复模式 浏览:808
生命令人忧 浏览:597
魔兽搬砖怎么选择服务器 浏览:771