[英]htaccess Redirect sub directories except index.php
我在www.mydomain.com/dir中有一個htaccess文件。
我想將請求從www.mydomain.com/dir/*重定向到www.mydomain.com/dir,但www.mydomain.com/dir/index.php除外
我嘗試了這個:
RewriteEngine on
RewriteCond DOCUMENT_ROOT/ !-f
RewriteRule ^/*$ index.php
我究竟做錯了什么?
這可能應該工作:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /dir/
RewriteRule (?!^index\.php$)^.+$ index.php [L,NC]
差不多了!
www.mydomain.com/dir/.htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (?!^index\.php$)^.+$ index.php [L,NC]
但是,當我訪問任何文件或子目錄的目錄 ,我得到404 index.php文件位於目錄和目錄到文件的任何請求或子目錄應該被重定向到目錄/ index.php文件 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.