[英]How to configure .htaccess for subdirectory
我在AWS上托管了一個WordPress站點,我很難配置mod_rewrite
以正常工作。
/root
|_ staging/
|_ live/
.htaccess
是WordPress的默認設置
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我可以訪問/staging/index.php/api
,我曾經訪問它,沒有像這樣的子目錄---.com/api
。
當我嘗試/staging/api
它顯示File not found
。
我試圖將.htaccess
更改為不同的東西,但沒有一個成功。
根目錄中沒有.htaccess
文件。
一些幫助將不勝感激=)
提前致謝。
試試這個代碼
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /staging
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /staging/index.php [L]
</IfModule>
注意:應在服務器配置中將AllowOverride設置為All 。 你可以從這里找到參考。 如何設置AllowOverride all
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.