2015-11-03 49 views
1

我試圖從URL重寫全自動

​​

自動重寫URL來

www.example.com/test_123jane 

我使用

RewriteRule ^test_([A-Za-z0-9-]+)/?$ test.php?title=$1 [NC,L]' 

但這並不改變自動。

+0

您是否試圖使用漂亮的網址?如果是這樣,你有來回往上,對吧? –

回答

0
RewriteEngine On 

RewriteCond %{THE_REQUEST} ^GET\ /test\.php\?title=([a-z0-9]+) [NC] 
RewriteRule ^test\.php$ /test_%1? [R=301,L,NC] 

RewriteRule ^test_([a-z0-9]+)$ /test.php?title=$1 [L] 

以上應該工作。

+0

我有這個問題,但它寫的URL不正確。它是這樣的:'http://www.example.com/test_123jane?title = 123jane' –

+0

@RustamzadeMahammad更新了我的回覆。忘記在上面重寫'%1'後添加'?'。 – hjpotter92

+0

stell無法正常工作:/ –