需要有关Mod Rewrite.htaccess父文件夹和1个子文件夹的帮助


Need help on Mod Rewrite .htaccess parent folder and 1 subfolder

我不是很擅长理解.htaccess重写,这一次让我头疼。

我有domain.com和一个名为:app/webroot/ 的文件夹

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

  2. 那就让我疯了。我在domain.com下有一个名为"system"的管理员文件夹。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]

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]