我需要從apache更改爲Nginx,但.htaccess
不適用於Nginx服務器。apache .htaccess到nginx重寫規則
我得到了以下在我的Apache .htaccess
:
RewriteEngine On
# always run through the indexfile
RewriteRule .$ index.php
# don't let people peek into directories without an index file
Options -Indexes
當我把一個.htaccess
Nginx的服務器上,該文件被由服務器中刪除。 在什麼樣的文件我必須把.htaccess
數據(名稱和後綴),以及如何重寫Nginx和我把文件放在哪裏?
我希望所有子目錄中的文件都要經過我的index.php
文件,這樣我可以從我index.php
文件中包含特定的文件...
我已經試過類似:
# nginx configuration
autoindex off;
location/{
rewrite .$ /index.php;
}
,但它不工作。該目錄看起來是這樣的:
── root
├── folder1
│ └── folder2
│ └── file.php
└── index.php
,所以如果我問root/folder1/folder2/file.php
我希望服務器加載root/index.php
,因爲我仍然有服務器的URL請求, 我可以從我index.php
包括root/folder1/folder2/file.php
它所有的工作都在我的apache安裝上,但不在Nginx服務器上。 請幫幫我。
編輯: 原來,nginx.conf
文件必須是根文件夾上方,如果你有機會到根文件夾上面的文件夾才能訪問。像服務器管理員訪問是必要的。
您是否發現** http://www.anilcetin.com/**或** http://winginx.com/en/ htaccess的**? – MonkeyZeus
是的和許多其他網站。我試圖把我的代碼放在nginx.conf和nginx.conf.txt文件夾中,但不起作用。 nginx服務器會自動刪除htaccess文件。代碼是否在htaccess文件中? – Medda86