簡體   English   中英

如何為子目錄配置.htaccess

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM