1
爲了測試的目的,我想追加一個查詢字符串(比如說testing = true)到我的網站請求的任何網址。將查詢字符串附加到所有使用.htaccess的網址
E.g.我想改變
- example.com
- example.com/product
- example.com/search?q=string
到
- example.com? testing = true
- example.com/product? 測試=真
- example.com/search?q=string & 測試=真
我嘗試這樣做:
RewriteRule ^/?(.*) http://example.com/$1?testing=true [L,R,NE]
,但它打破了現場。不是專家。
任何想法?
編輯:
我要補充,我使用CodeIgniter(PHP)和我目前的.htaccess的工作是這樣的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
不幸的是,它什麼都沒做。頁面使用正常的URL加載,查詢字符串不會被追加。 – lesssugar 2014-12-04 15:36:16
現在用'R'標誌嘗試更新的代碼。 – anubhava 2014-12-04 15:36:54
工程像魅力! – lesssugar 2014-12-04 15:38:18