Forum Moderators: phranque

Message Too Old, No Replies

RedirectMatch

         

Anvar

12:08 am on Dec 31, 2011 (gmt 0)

10+ Year Member



Hi,
I want to redirect pages. For example.
http://www.site.com/ru/file-id-11.htm to http://www.site.ru/file-id-11.htm.


I tried with RedirectMatch. It looks like this


RedirectMatch 301 ^/ru/file-id-(.*)\.htm$ http://www.site.ru/file-id-$1.htm

It works fine. But my link looks like this
http://www.site.ru/file-id-11.htm?id=11.


What I am doing wrong here.

[edited by: Anvar at 12:11 am (utc) on Dec 31, 2011]

Anvar

12:10 am on Dec 31, 2011 (gmt 0)

10+ Year Member



Or is there any other method?

g1smd

12:15 am on Dec 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use RewriteRule for all of your rules. Forget about Redirect and RedirectMatch.

RewriteRule can be configured to do both redirects and rewrites and is much more versatile.

Add a question mark to the target URL to suppress query string data.

Anvar

4:18 pm on Dec 31, 2011 (gmt 0)

10+ Year Member



Thanks for response. Yep, I tried it. But how to make it for dynamic pages? I have searched, but could not find anything useful for dynamic pages.

g1smd

6:26 pm on Dec 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If by dynamic you mean query strings, they pass through unchnaged unless you remove or alter them.

Detecting their value is as easy as using a preceding RewriteCond looking at %{QUERY_STRING}.