开发者

How to replace escape codes in url and redirect it using htaccess?

开发者 https://www.devze.com 2023-04-11 04:52 出处:网络
I need to redirect multiple urls from this format: http://site.com/gallery.php%3Fpage%3D12 开发者_JS百科

I need to redirect multiple urls from this format:

http://site.com/gallery.php%3Fpage%3D12

开发者_JS百科

(the 12 at the end is the page number, i have many links like this with different numbers at the end)

to this:

http://site.com/gallery.php?page=12

how to i write a rule in htaccess that will replace those chars in all the urls and redirect them to the correct urls?


By default URLs in mod_rewrte are decoded(unescaped) so there is no need to escape(encode) them!


As mentioned by "Death", there is no need to replace the chars, this simple rule did the trick:

RewriteRule ^gallery\.php\?page\=(.*) http://site.com/gallery.php?page=$1 [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号