Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Post Using question marks in mod_rewrite (query_string)


    Hi There,

    We have a website that has pages which dont exist any more and i'm trying to redirect the old link to the homepage. This works for most rules but once I include a ? in the link it doesnt work.

    Due to being a new member I cant post links heh, so [link] is where im placing my link i want to be redirected too

    Heres and example of a working one I have:
    Code:
    RewriteRule ^email-marketing\.php$ [link] [R=301,L]
    Now as soon I do something like this:
    Code:
    RewriteRule ^index\.php\?page=contact$ [link]
    it doesnt pick it up / work. I cannot find anything helpful in the log either

    Ive also tried this that doesnt work:
    Code:
    RewriteCond ${QUERY_STRING} 	=^index.php?page=contact$
    RewriteRule ^index\.php\?page=contact$	[link]
    this does also not work.

    Im sure i'm missing something simple here. Any help / advice would be greatly appreciated

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    actually your last rewrite condition is not quite correct it should look more like
    Code:
    RewriteCond %{QUERY_STRING} page=contact
    RewriteRule ^index\.php [link] [NE,R=301]
    the options at the end are adjustable YMMV. does that help any?
    linux user # 503963

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •