Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts

    redirect from Query String to static page

    I am trying to create a rule that will permanently redirect the url

    http://www.chantillylane.com/home.php?C17.106

    to this url

    http://rvahc.jtrvm.servertrust.com/category-s/42.htm

    Can someone please help me? this is what I have come up with so far, but it results in an internal error.

    Code:
    RewriteCond %{QUERY_STRING} ^?C17.106$
    RewriteRule ^/home.php$ http://rvahc.jtrvm.servertrust.com/category-s/42.htm [L,R=301]
    thank you

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I assume you have RewriteEngine On somewhere in the file too? The QUERY_STRING variable doesn't contain the question mark so drop that from the RewriteCond. If you are placing these directives in a .htaccess file, then also remove the forward slash from the /home part in your RewriteRule (if you are placing it in the VirtualHost however, it should be there). You should probably escape the dot in the RewriteCond by adding a forward slash to the start of it. Other than that you should be good to go.

    If you still get the 500 server error then perhaps mod_rewrite isn't enabled. You can check by wrapping your rewrite directives in an IfModule block,

    Code:
    <IfModule mod_rewrite.c>
       # your code here
    </IfModule>
    It won't make it work, but if it stops your server from crashing then you know mod_rewrite isn't enabled.

    On a side note, I generally find that it's best, when working with rewrites, to always use 302 status code. Once you are happy everything works OK, you can change it to a 301, but testing with a 301 is a pain because your local DNS / browser can cache the redirect meaning you may not be seeing what your current code is really doing.

  • Users who have thanked Cags for this post:

    reach100 (10-04-2011)

  • #3
    New Coder
    Join Date
    May 2008
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts
    great, that worked perfectly. thank you.


  •  

    Posting Permissions

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