2013-08-28 83 views
1

我不太瞭解.htaccess重寫,這一個讓我頭疼。需要幫助Mod重寫.htaccess父文件夾和1個子文件夾

我有domain.com和1個文件夾名爲:app/webroot/

  1. 我想要的一切:domain.com/*將被改寫到文件夾domain.com/app/webroot/*

  2. 那麼這就是讓我瘋了。我有1個管理員文件夾,在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] 

回答

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]