0

http://www.example.com/index.php?page=property_submit&edit=1&pid=978國防部URL重寫不工作

我想這個URL重寫

http://www.example.com/index/property_submit/1/978

我嘗試用下面的代碼重寫,但它不工作:

RewriteRule ^index/([a-zA-Z0-9_-]+)/([0-9]+)$ index.php?$1=$1 

RewriteRule ^index/([a-zA-Z0-9_-]+)/([0-9]+)/$ index.php?$1=$1 [QSA] 

全碼如下:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example.com 
RewriteRule (.*) example.com/$1 [R=301,L] 
RewriteRule ^index/([a-zA-Z0-9_-]+)/([0-9]+)$ index.php?$1=$1 
RewriteRule ^index/([a-zA-Z0-9_-]+)/([0-9]+)/$ index.php?$1=$1 [QSA] 
+0

而「不工作」的意思_what_?你的日誌文件中有錯誤嗎?它是否改寫到錯誤的位置?宇宙是否內爆? – arkascha

+0

網址沒有變化..still顯示舊的網址 –

+0

你的日誌文件呢?您的http服務器錯誤日誌中的任何條目? – arkascha

回答

0

你必須對原始請求的工作來處理重定向:

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^GET\ /index\.php\?page=([^\s&]+)&edit=(\d+)&pid=(\d+) [NC] 
RewriteRule^/index/%1/%2/%3? [R=301,L,NC] 

RewriteRule ^index/([\w-]+)/(\d+)/(\d+)$ /index.php?page=$1&edit=$2&pid=$3 [L] 
+0

這是非常傷心的說傢伙..沒有在我的網站 –

+0

http://example.com/index.php?page = home –

+0

可以請你幫我至少在這個簡單的網址 –

0

您的模式與您想要重寫的網址不匹配。

考慮這個:

RewriteEngine on 
RewriteRule ^index/property_submit/([0-9]+)/([0-9]+)$ index.php?page=property_submit&edit=$1&pid=$2 [L] 

我覺得對「property_submit」字符串匹配,使您的策略更安全,因爲你不匹配你可能不要重寫任意URL。

+0

沒有改進..顯示舊的地址 –

+0

@JithuJohnson我還在研究這個模式。當然你嘗試了當前版本? – arkascha

+0

我嘗試過但不工作..沒有改變 –