Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The below are all my .htaccess entry:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.acethehimalaya\.com$ [NC]
RewriteRule (.*) http://www.acethehimalaya.com/$1 [R=301,L]

redirect 301 /brochure_request.php http://www.acethehimalaya.com/request-brochures.html
redirect 301 /testimonials.php http://www.acethehimalaya.com/testimonials.html

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.acethehimalaya.com/$1 [R=301,L]

But the last entry for redirecting:




is not working. The code i have used is below:

RewriteCond   %{REQUEST_URI}    ^/tripdetails.php$
RewriteCond   %{QUERY_STRING}   ^trip_id=8$
RewriteRule   ^(.*)$ http://www.acethehimalaya.com/destinations/nepal/nepal-trekking/everest-base-camp-budget-trek.html  [R=301,L]

Its been like days and i m struck so can anybody figure this out.

share|improve this question
The server is currently issuing a 301 redirect for that URL, except the Location: HTTP response header is blank?! – w3dk Jan 29 '13 at 19:26

Why not use a simple Redirect 301?

Redirect 301 /tripdetails.php?trip_id=8    http://www.acethehimalaya.com/destinations/nepal/nepal-trekking/everest-base-camp-budget-trek.html
share|improve this answer
The edit has already been made by @Stephen, but I think it's worth mentioning... the URL-path (2nd argument to the Redirect directive) should be a root-relative path (beginning with a slash), not an absolute URL. – w3dk Jan 29 '13 at 22:18
I tried the simple redirect but it dint work so i thought it was because of string variable URl – user2014989 Jan 30 '13 at 4:36
Oops. Thanks Stephen. – puppybeard Jan 31 '13 at 12:40

You've already been given a working solution (see @puppybeard post), but just to clear things out and answer why your redirect rules didn't work:

What you've done is ended your conditional strings with a dollar sign $ that signals to the redirect engine parser that the string sought should end exactly with whatever preceded the $ sign. The opposite to $ is ^ sign that signals the string sought should start with whatever follows this sign. Since you put ^/tripdetails.php$ between both 'starts with' ^ and 'ends with' $ the only URI that would match it is '/tripdetails.php' itself. Since QUERY_STRING is a part of REQUEST_URI, this wouldn't work. However, even if that exact URI was used, it wouldn't redirect due to another rule following it that would only match the query part of the URI ^trip_id=8$ (or exactly 'trip_id=8'). They're two mutually exclusive sets of rules. If you prefer redirecting with rewrite conditions, then your code would look like:

RewriteEngine On 
RewriteCond   %{REQUEST_URI}    ^/tripdetails.php [NC]
RewriteCond   %{QUERY_STRING}   trip_id=8(&|$) [NC]
RewriteRule   ^(.*)$ http://www.acethehimalaya.com/destinations/nepal/nepal-trekking/everest-base-camp-budget-trek.html  [R=301,L]

I've added NC (no-case) flag so the rule also supports same URIs that were typed with (some or all) capital characters.

If it doesn't matter to you which solution you use, then better use the one provided by @puppybeard as it's more straight-forward and easier to control. Note though, Redirect directive is case-sensitive.


share|improve this answer
I used both the solution but it doesnt get redirected and i m in mess already :(( – user2014989 Jan 30 '13 at 4:40
I have been posting this questions for couple of days now and changed many entries..everyone suggesting me the code says it works for them but the problem is it doesnt work for me. The other entries i have used are working so i guess my RewriteEngine is on...i dont have much knowledge on this issue and my web developers are not working on it...i m just frustrated you know :(( – user2014989 Jan 30 '13 at 4:52
I have got so many questions now....confused like anything! – user2014989 Jan 30 '13 at 5:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.