htaccess redirect with variables

2019-09-21 01:58发布

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条回答
贼婆χ
2楼-- · 2019-09-21 02:23

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]
查看更多
登录 后发表回答