Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect for Dynamic URL

301 Redirect for Dynamic URL

         

Digino

8:17 am on May 19, 2010 (gmt 0)

10+ Year Member



Hi guys,
I'm trying to do a 301 redirect from a dynamic page to a static one.

The dynamic URL is http://www.example.com/?id=109 and I'm trying to redirect to http://www.example.com/programme/. The below code is throwing up an error for me and I'm getting an error when I enable the below htaccess redirect.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=109$
RewriteRule ^\$ http://www.example.com/programme/ [R=301,L]

[edited by: jdMorgan at 12:35 pm (utc) on May 19, 2010]
[edit reason] example.com [/edit]

g1smd

10:36 am on May 19, 2010 (gmt 0)

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



"Not working" is so vague that the only answer I can logically give you is, "it's broken".



The
^\$
pattern isn't valid. It's looking for a URL Request like
example.com/[b]$[/b]
or
example.com/[b]$[/b]<something>
.

See [webmasterworld.com...] for a very similar question and full answer.

Use 'example.com' to stop the forum messing with your code.

    jdMorgan

    12:40 pm on May 19, 2010 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    If you do not have any other working rules, it is possible that you may need to add

    Options +FollowSymLinks

    or

    Options +FollowSymLinks -Indexes -MultiViews

    ahead of your RewriteEngine directive, in order to enable mod_rewrite.

    This is documented in the Apache mod_rewrite documentation, and if this is the problem, your server error log will say so.

    As g1smd pointed out, the "^\$" pattern is incorrect, and for your example URL, should be just "^$"

    Be aware that redirecting this request without explaining the action may confuse your visitors. It is generally a much better idea to replace the page with an explanation that it is obsolete or gone, and then provide links to your home page, related-category or -articles pages, HTML site map page, and site search function, as appropriate.

    Jim