2016-12-17 45 views
1

Im在我的.htaccess文件上有一些重定向規則的問題。 我想創建一個規則來將我的博客內容重定向到友好的網址。 當前的URL結構是:重寫url /blog/article.php?id=hello到/blog/hello.html

/blog/article.php?id=hello

,我想它更改爲:

/blog/hello.html

這是我的規則,到目前爲止,我不似乎能夠找到的錯誤:

RewriteEngine On 
Options -MultiViews 
RewriteRule ^blog/([a-z,A-Z,0-9]+)$.html blog/article.php?id=$1 [L] 

任何幫助,將不勝感激。

+0

我碰巧有一個htaccess的發電機來解決它。規則是: RewriteRule^blog /([^ /] *)\。html $ /blog/articulo.php?id=$1 [L] 我使用的生成器是:http://www.generateit。 net/mod-rewrite/index.php 謝謝! – Gekyzo

回答

1

由於您在模式中放置了$,重寫模塊無法將您的請求與表達式匹配。

它應該是:

Options -MultiViews 
RewriteEngine On 
RewriteRule ^blog/([\da-z]+)\.html$ blog/article.php?id=$1 [L,NC] 
+0

它似乎不適用於我。我正在使用Apache 2.4。 我試圖在本地主機服務器和我的真實網頁,沒有區別。 關於我該怎麼做的任何想法?謝謝。 – Gekyzo