PDA

View Full Version : .htaccess redirect problem



maxvee8
04-26-2011, 11:00 AM
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)...



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



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?

angst
04-27-2011, 02:20 PM
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.

oesxyl
04-27-2011, 08:13 PM
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)...



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



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