Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirection problem

         

maxtter

7:32 pm on Nov 13, 2011 (gmt 0)

10+ Year Member



I have this url

http://www.example.com/news/page.php?s=page_name


which doesn't exist any more. I would like to redirect it to home page /

Any help appreciated :)

lucy24

10:11 pm on Nov 13, 2011 (gmt 0)

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



What have you tried so far? Read any six consecutive threads in this forum and you should have enough information to keep you busy.

maxtter

10:19 pm on Nov 13, 2011 (gmt 0)

10+ Year Member



I was busy for hours, but no luck :( I think this is the best I have so far, but it's not working:

RewriteCond %{QUERY_STRING} ^s\=(.*)$
RewriteRule ^/news/page.php/index\.php$ /? [R=301,L]

lucy24

12:36 am on Nov 14, 2011 (gmt 0)

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



You don't need to escape literal equals signs.

The Condition as written will work on any query that begins with "s=". You don't need capturing parentheses or a closing anchor; in fact you don't even need the .* if all that matters is s=

The Rule as written will take any request for the exact page

www.example.com/news/page.php/index\.php

(whoops! forgot to escape the first literal period) and redirect it to the home page after deleting the whole query string.

Is that what you intended? Can't help but suspect it isn't, what with those two separate "php" elements.

:: memo to self: write up boilerplate on what to say instead of "it's not working" ::

maxtter

8:08 am on Nov 14, 2011 (gmt 0)

10+ Year Member



All I need is to this url

http://www.example.com/news/page.php?s=page_name

redirect to the home page.

So all after www.example.com matters, not just s=

g1smd

12:35 pm on Nov 14, 2011 (gmt 0)

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



The
%{QUERY_STRING}
to match with the
RewriteCond
RegEx is
(^|&)s=page_name(&|$)


The path to match with the
RewriteRule
RegEx pattern is
^news/page\.php


The target URL is
http://www.example.com/


The
[R=301,L]
flags will make this a 301 redirect.

What's the problem?

maxtter

1:17 pm on Nov 14, 2011 (gmt 0)

10+ Year Member



It works :) No problem any more :)
Thank you very much!