htaccess redirect with variables

帅比萌擦擦* 提交于 2020-01-07 08:02:18

问题


I realise there are similar questions but I'm trying to work out how I can rewrite the following URL:

http://www.myWEBaddress.com/?month=200904

to

http://www.myWEBaddress.com/my-page.php?month=200904 

Regards


回答1:


Add the following to the .htaccess file in the root directory of your site.

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} (^|&)month= [NC] 
RewriteRule ^ my-page.php [L]

If you want to change the URL that the user sees in their browser address bar, change the last rule to

RewriteRule ^ my-page.php [L,R=301]


来源:https://stackoverflow.com/questions/9113747/htaccess-redirect-with-variables

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