[英]Prevent .htaccess rules to the child folder
这是我的文件夹结构
www.mywebsite.com
www.mywebsite.com/app
www.mywebsite.com/app/firstproject
www.mywebsite.com/app/secondtproject
在根目录中,我安装了wordpress。 它允许我访问www.mywebsite.com/app
但是当我尝试访问www.mywebsite.com/app
它总是显示page not found
我可以猜到这是由于根文件夹中的.htaccess
。
这是.htaccess
根文件夹
# BEGIN 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>
# END WordPress
我试图重写.htaccess
由具有在下面的代码到子文件夹.htaccess
应用程序文件夹,但它显示了相同的页面没有找到错误。
RewriteRule ^app/ - [L]
我如何才能访问www.mywebsite.com/app/firstproject
而不会出现该错误?
将所有规则写入htaccess根文件中。 添加RewriteRule ^ app / firstproject $-[L]以防止在此路径中进行重写。 要在/ firstproject中进行进一步重写,您需要类似于Web root的条件和规则。
RewriteEngine On
RewriteBase /
RewriteRule ^app/firstproject$ - [L] #add longer path first
RewriteRule ^index.php$ - [L] #no need to escape \.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
app/.htaccess
根.htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(index\.php$|app/) - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.