2015-10-11 112 views
0

我已閱讀了許多帖子和文檔,但仍無法完成此項工作。可能缺少一些微不足道的東西。無法刪除.htaccess中的查詢字符串重寫

我想www.domain.no/?id=val改寫到www.domain.no/index.php

.htaccess的代碼是

RewriteEngine on 
RewriteBase/

# Test that pathname exists, and is NOT a directory. 
RewriteCond %{REQUEST_FILENAME} !-d 
# Test that the pathname with a .php extension exists, and is a regular file. 
RewriteCond %{REQUEST_FILENAME}\.php -f 
# Test that a non-empty query string exists 
RewriteCond %{QUERY_STRING} . 
# Re-write to file with .php extension, without query string 
RewriteRule ^(.*)$ $1.php? [L] 

有什麼建議?

+0

應該是'的RewriteCond%{QUERY_STRING}^ID = VAL $' – hjpotter92

+0

我的理解是, 「的RewriteCond%{QUERY_STRING}」匹配任何查詢字符串,這是我想要的。我不想限制重寫任何特定的查詢。 – Svea

+0

「www.domain.no/?id = val'的問題:沒有擴展名爲.php的文件... – Croises

回答

0

開始試圖說:

RewriteEngine on 
RewriteBase/
RewriteCond %{QUERY_STRING} . 
RewriteRule ^(.*)$ $1? [R=302,L] 
相關問題