可能我的問題與其他標題重複,但我已經閱讀了太多的標題,並與谷歌多次檢查。所以如果它重複,我很抱歉。Apache的URL重寫規則和正則表達式
現在我有一個網址:
www.mysite.com/profile.php
我使用這個URL重寫規則:
RewriteRule ^([A-Za-z0-9-_]+)/?$ profile.php?username=$1 [NC,L]
而且我可以改變我的網址,如:
www.mysite.com/username
然後,我需要更新我的網址與其他獲取參數:
www.mysite.com/username/photos
在這個部分,我有一個像網址:
www.mysite.com/profile.php?username=xxx&w=photo
我已經試過這個URL規則的URL上面:
RewriteRule ^([A-Za-z0-9-_]+)/?$/?$ profile.php?username=$1&w=$2 [NC,L]
,但它不能正常工作。請幫忙。
非常感謝。
------- ------ UPDATE
現在我可以用profile.php它應該是。但其他重寫規則被破壞。這樣我目前的.htaccess文件:
RewriteEngine On
RewriteRule ^([\w-]+)/([\w-]+)/?$ profile.php?username=$1&w=$2 [QSA,L]
RewriteRule ^([\w-]+)/?$ profile.php?username=$1 [QSA,L]
RewriteRule ^p/timeline timeline.php [NC,L]
RewriteRule ^p/notifications notifications.php [NC,L]
你能否再次檢查我的問題與我的更新。 – Mehmet