2017-07-14 59 views
0

我在這裏找不到它,所以有人可以幫我解決這個正則表達式問題。扭矩線重寫規則

我的網址是:

event/12345-12345-12345 

但它不能用這種 '重寫規則'

RewriteRule ^event/([a-zA-Z0-9-]+)([/]*) /event.php?event=$1 [NC] 

調試或找到我的正則表達式的解決方案: https://regex101.com/r/WcSoFP/1

+0

[你的模式運作正常的(https://regex101.com/r/WcSoFP/1)甚至在PHP。這個問題是無題的,因爲沒有錯誤。 –

+0

這個減1是不好的動機。因爲你可以給我一個編輯選項。不好的選擇人! –

+0

[提示調試.htaccess重寫規則](https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules) –

回答

2

你忘了在您的正則表達式中轉義/

應該是這樣:

RewriteRule ^event\/([a-zA-Z0-9-]+)([\/]*) /event.php?event=$1 [NC] 
+1

有沒有必要轉義一個'/'符號在RewriteRule中,它不使用正則表達式分隔符。 OP正則表達式[原樣](https://regex101.com/r/WcSoFP/1),即使在PHP中也是如此。 –

+0

有用了嗎@WiktorStribiżew:) – funilrys

+0

@PieterDijkstra這工作? – funilrys