2015-12-15 504 views
1

我有這個網址:127.0.0.1/test.php?name=john.smith即成爲127.0.0.1/profile/john.smith這個規則:重寫規則的友好URL名稱

RewriteRule ^profile/([^*]+)$ test.php?name=$1 [L] 

我想什麼是刪除/資料/簡單地有127.0.0.1/john.smith

我遇到了一些問題,找到正確的重寫規則。

感謝您的幫助。

回答

1

試試這個規則:

# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ test.php?name=$1 [L,QSA] 
+1

Woaw,令我印象深刻。這工作得很好。十分感謝你。 – Weebee