2012-01-12 60 views
1

沒事的......所以我有這個CSS打捆使用以下鏈接:使用mod_rewrite擺脫問號

http://www.example.com/min/?b=wp-content/themes/mytheme&f=style.css,boxes.css,mods.css,scripts.css

參數B是css文件夾的網址和參數f是CSS文件要得到。

但是,爲了幫助我的緩存,我想問號消失了。如果可能的話,是這樣的:

http://www.example.com/min/b=wp-content/themes/mytheme&f=style.css,boxes.css,mods.css,scripts.css

我試過如下:

RewriteEngine On 
RewriteRule ^/([^/\.]+)/?$ index.php?b=$1 [L] 

不用說,它沒有工作。

+1

看來問題出在斜線b值 – Alice 2012-01-12 11:41:50

回答

0

你的規則是要循環,你可以嘗試在規則的前面加上一個條件,使它看起來像這樣:

RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/index.php 
RewriteRule ^/([^/\.]+)/?$ index.php?b=$1 [L] 

但似乎,根據您的網址範例,你想要的東西更多像這樣:

RewriteRule ^min/b=(.*)$ index.php?b=$1 [L] 
0

這看起來像一個不尋常的事情,你想從查詢字符串擺脫?但要保留符號即&

無論如何,如果這是你真正想要的,那麼你可以把這個代碼在你的.htaccess什麼:

Options +FollowSymLinks -MultiViews 
RewriteEngine on 

RewriteRule ^min/b=([^;]*);f=(.*)$ min/?b=$1&f=$2 [L] 

此規則將在內部重定向http://www.example.com/min/b=wp-content/themes/mytheme;f=style.css,boxes.css,mods.css,scripts.csshttp://www.example.com/min/?b=wp-content/themes/mytheme&f=style.css,boxes.css,mods.css,scripts.css

+0

問題是我的緩存不會存儲帶「?」的文件在他們的網址。我將如何去除&符號? – Alice 2012-01-16 08:46:47

+0

哦,那你想要你的最終URI是什麼? – anubhava 2012-01-16 09:54:01

+0

我不確定什麼是傳統的 – Alice 2012-01-16 15:16:08