1

我不太了解 .htaccess 重写,这让我很头疼。

我有domain.com, 和 1 个文件夹称为:app/webroot/

  1. 我想要一切:domain.com/*将被重写到文件夹domain.com/app/webroot/*

  2. 然后这让我发疯。我有 1 个管理员文件夹,"system"也在 domain.com 下调用。domain.com/system 下的所有内容都不会被重写到 webroot。

  3. 最后,我想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&param=$3 [NC,L,QSA]
4

1 回答 1

1

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&param=$4 [NC,L,QSA]
于 2013-08-28T22:18:43.737 回答