[英]How to configure .htaccess for subdirectory
I have a WordPress site hosted on AWS and I am having a hard time to configure mod_rewrite
to work correctly. 我在AWS上托管了一个WordPress站点,我很难配置
mod_rewrite
以正常工作。
/root
|_ staging/
|_ live/
The .htaccess
is the WordPress default .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>
I can access /staging/index.php/api
which I used to access it without subdirectories like this ---.com/api
. 我可以访问
/staging/index.php/api
,我曾经访问它,没有像这样的子目录---.com/api
。
When I try /staging/api
it shows File not found
. 当我尝试
/staging/api
它显示File not found
。
I tried to change the .htaccess
to different thing but none of them was successful. 我试图将
.htaccess
更改为不同的东西,但没有一个成功。
There are no .htaccess
file in the root directory. 根目录中没有
.htaccess
文件。
Some help would be appreciated =) 一些帮助将不胜感激=)
Thanks in advance. 提前致谢。
Try this code 试试这个代码
<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>
Note: The AllowOverride should be set to All in server configuration. 注意:应在服务器配置中将AllowOverride设置为All 。 You can find the reference from here.
你可以从这里找到参考。 How to Set AllowOverride all
如何设置AllowOverride all
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.