2015-10-13 13 views
0

我發現這篇文章最符合我的需求,我只是沒有得到這個完全符合我的需求。 How can I change the URL in the browser by htaccess?Smarty美化使用控制器時的URL

我的URL像這樣:

mysite.de/index.php?cl=services 

我很想有這樣的事情:

mysite.de/services 

什麼是這樣做的最簡單的方法?

+1

當你說你可以'滿足你的需求,你需要什麼?什麼是'cl =',它是一個頁面名稱或ID,參數值中可能包含哪些字符等。請在您的帖子_中填寫,並在有人要求澄清時儘量不要回復。 –

+1

歡迎來到Stack Overflow。我已經修復了一些英文問題。我還通過給他們添加4個空格來標記網址。如果您發佈了當前的工作,它可以幫助其他人更快地幫助您。到目前爲止你嘗試過什麼,它取得了什麼成就。 –

回答

0
RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?p=profile&id=$1 

應適用於:

www.domain.com/index.php?p=profile&id=20 

www.domain.com/profile/20/profile-friendly-name 
+0

當我想要重新路由每個電話時它看起來像什麼樣 - 不僅與一個特定頁面相關 –

+0

您是否嘗試過 – Hexana

0

爲了您的具體的例子這將是

Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteRule ^services$ /index.php?cl=services [L] 

如果需要多個網址,你需要多個RewriteRule秒。或者你可以將它們組合在一起(即RewriteRule ^(services|contact)$ /index.php?cl=$1),但多條規則更容易閱讀和維護。