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