我不是很擅长理解.htaccess重写,这一次让我头疼。
我有domain.com
和一个名为:app/webroot/
的文件夹
-
我想要一切:
domain.com/*
将被重写到文件夹domain.com/app/webroot/*
-
那就让我疯了。我在domain.com下有一个名为
"system"
的管理员文件夹。domain.com/system下的所有内容都不会被重写到webroot。 -
最后,我希望
system/something
将被重写为/system/index.php?subpage=something
真的很抱歉,如果你认为这很容易,而我做不到,但我已经坚持了一整天了。
以下是我尝试做的:
RewriteEngine on
RewriteRule ^(.*)$ app/webroot/$1 [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^/?(system)/?([^/]+)/?$ /system/index.php?subpage=$1 [NC,L,QSA]
RewriteRule ^/?(system)/?([^/]+)/([^/]+)/?$ /system/index.php?subpage=$1&action=$2 [NC,L,QSA]
RewriteRule ^/?(system)/?([^/]+)/([^/]+)/([^/]+)/?$ /system/index.php?subpage=$1&action=$2¶m=$3 [NC,L,QSA]
nvm,我得到了。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ app/webroot/$1 [L]
RewriteRule ^/?(system)/?([^/]+)/?$ /system/index.php?subpage=$2 [NC,L,QSA]
RewriteRule ^/?(system)/?([^/]+)/([^/]+)/?$ /system/index.php?subpage=$2&action=$3 [NC,L,QSA]
RewriteRule ^/?(system)/?([^/]+)/([^/]+)/([^/]+)/?$ /system/index.php?subpage=$2&action=$3¶m=$4 [NC,L,QSA]