* wildcard htaccess 301 redirect

Discussion in 'Coding Help' started by Cormac, Apr 16, 2008.

  1. Cormac

    Cormac New Member

    I'm trying to setup a redirect so that any request to any page which ends in ?page_id gets redirected to the homepage of the site.
    The following rule is placed within the htaccess file but it throws up an internal server error:

    RewriteRule ^?page_id=(.*)$ /http://site.something.com [L,R=301]
    Any ideas?
  2. paul

    paul Ninja

    RewriteRule ^?page_id=(.*)$ [COLOR=Red][U][B]/[/B][/U][/COLOR]http://site.something.com [L,R=301]
    this doesn't look right, i.e. the forward slash...
  3. louie

    louie New Member

    try this
    RewriteRule ^(.*)?\?page_id=(.*)?$ [URL]http://site.something.com[/URL] [L,R=301]
    #or this
    RewriteRule ^(.*)?([\?])page_id=(.*)$ [URL]http://site.something.com[/URL] [L,R=301]
    also you have a "/" in front of the http:// which shouldn't be there
  4. louie

    louie New Member

    or try this option
    [FONT=Courier New]RewriteCond %{QUERY_STRING} ^page_id=(.*) 
    RewriteRule /* [URL]http://site.something.com[/URL][/FONT][FONT=Courier New] [R=301,L][/FONT][FONT=verdana][SIZE=2][/SIZE][/FONT]

Share This Page