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
    Regular Coder maxvee8's Avatar
    Join Date
    Feb 2008
    Location
    UK
    Posts
    185
    Thanks
    19
    Thanked 18 Times in 18 Posts

    Question .htaccess redirect problem

    Hi iam completly confused by .htaccess so any help is appreciated.

    I want to redirect a url but it doesnt seem to work (full code below)...

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.test-url.com
    RewriteRule (.*) http://www.test-url.com/$1 [R=301,L]
    Redirect 301 /2462-make-an-enquiry.php http://www.test-url.com/make-an-enquiry.php
    Redirect 301 /679-view-by-colour.php?t=2&colour_id=46 http://www.test-url.com/679-view-by-colour.php?t=2&colour_id=66
    The one that isnt working is

    Code:
    Redirect 301 /679-view-by-colour.php?t=2&colour_id=46 http://www.test-url.com/679-view-by-colour.php?t=2&colour_id=66
    any one know how to make this work, Thanks?
    "I have not failed, I've found 10,000 ways that don't work" Thomas Edison

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    Hey Max, i've never run into this issue myself, but did a little reading and this is what I found:

    A dynamic page is one generated by a database driven application, such as blog or forum software. A file name is appended by a query string, looking something like this:

    http://www.example.com/page.php?id=13

    Where a query string is used, the 301 redirect solution for static pages above will not work; you'll need to use a rewrite solution. Using the page.php?id=13 example, here's what you'll need to use in your htaccess file:

    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^id=13$
    RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

    In the example above the id=13 should be replaced with the query string of the page you wish to redirect and the page.php with the name of your file prior to the query string.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by maxvee8 View Post
    Hi iam completly confused by .htaccess so any help is appreciated.

    I want to redirect a url but it doesnt seem to work (full code below)...

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.test-url.com
    RewriteRule (.*) http://www.test-url.com/$1 [R=301,L]
    Redirect 301 /2462-make-an-enquiry.php http://www.test-url.com/make-an-enquiry.php
    Redirect 301 /679-view-by-colour.php?t=2&colour_id=46 http://www.test-url.com/679-view-by-colour.php?t=2&colour_id=66
    The one that isnt working is

    Code:
    Redirect 301 /679-view-by-colour.php?t=2&colour_id=46 http://www.test-url.com/679-view-by-colour.php?t=2&colour_id=66
    any one know how to make this work, Thanks?
    and if you remove or comment first Redirect second will work?

    best regards


  •  

    Tags for this Thread

    Posting Permissions

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