我有一些目录:
/
/dash
/something
我想让htaccess将所有流量重定向到它的子文件夹index.php,当我键入它时可以 example.com/dash或example.com/something
但是我的问题是当我尝试类似example.com/dash/login或example.com/dash/another之类的东西时 在这种情况下,我将重定向到/目录
这是我在/目录中的htaccess
https:// we.tl/t-NtTDlYKBHr
Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!dash/)(.+)$ /index.php?u=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^dash/(.+)$ /dash/index.php?u=$1 [NC,QSA,L]
在/ dash
中RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
https:// we.tl/t-lhgQ03tTGE
答案 0 :(得分:1)
我不是这方面的专家。但我想你是通过这样的方式实现的。
将此文件放在您的父目录中
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^none/ none/index.php [NC,L,QSA]
RewriteRule ^dash/ dash/index.php [NC,L,QSA]
RewriteRule ^something/ something/index.php [NC,L,QSA]
RewriteRule ^ index.php [NC,L,QSA]
如果将htaccess放在每个目录中,也可以在所有目录中使用它。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [NC,L,QSA]