HTAccess rewrite dynamic page url

半城伤御伤魂 提交于 2020-01-05 12:12:49

问题


thanks for your help in advance

Basically i have made a dynamic url website http://planet-dj-surrey.com/

I cant seem to figure out the code for the htaccess file to redirect a dynamic page and make it cleaner.

for example i want http://planet-dj-surrey.com/index.php?page=designprocess to be changed to

http://planet-dj-surrey.com/designprocess/

currently i have this but it does not seem to be working,

RewriteEngine On
RewriteRule   ^/dropdownchoice/$   index.php?page=dropdownchoice  [NC]

Thanks in advance


回答1:


You need to lose the leading slash:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.php?page=$1  [NC]



回答2:


Here is a simple example:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^post-(.*)-([0-9]+)\.html$ post.php?post_name=$1&post_id=$2 [L]


来源:https://stackoverflow.com/questions/21662770/htaccess-rewrite-dynamic-page-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!