Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-26-2011, 11:00 AM   PM User | #1
maxvee8
Regular Coder

 
maxvee8's Avatar
 
Join Date: Feb 2008
Location: UK
Posts: 185
Thanks: 19
Thanked 18 Times in 18 Posts
maxvee8 is an unknown quantity at this point
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
maxvee8 is offline   Reply With Quote
Old 04-27-2011, 02:20 PM   PM User | #2
angst
Senior Coder

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

Quote:
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.
angst is offline   Reply With Quote
Old 04-27-2011, 08:13 PM   PM User | #3
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Tags
.htaccess

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:12 PM.


Advertisement
Log in to turn off these ads.