導航:首頁 > 編程語言 > 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相關的資料

熱點內容
信號分析pdf 瀏覽:925
暴力刪除命令 瀏覽:801
qt如何編譯加快速度 瀏覽:903
php添加數據sql語句 瀏覽:717
免費的小說app有什麼 瀏覽:405
螺桿壓縮機進氣閥動畫 瀏覽:651
兩台伺服器如何做負載均衡 瀏覽:227
程序員的工資是漲的嗎 瀏覽:813
視頻存儲伺服器可以干什麼 瀏覽:463
創建文件夾安裝失敗怎麼回事 瀏覽:832
程序員高考隔了幾年 瀏覽:822
雲伺服器是哪一層 瀏覽:22
jit編譯器的jit什麼意思 瀏覽:330
我想清理手機中空白文件夾 瀏覽:976
電腦e盤文件夾刪不掉怎麼辦 瀏覽:607
外圓凹圓弧編程 瀏覽:461
html5編程題 瀏覽:839
乾燥機製冷壓縮機一開就跳動 瀏覽:388
吉林壓縮空氣流量監測 瀏覽:618
根據地址獲取經緯度php 瀏覽:13