Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to redirect a url http://domain.com/?p=106 to http://domain.com/?p=110

My .htaccess file looks like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=106
RewriteRule / http://domain.com/\?p=110 [L,R=301]

But I can't seem to get it to work.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

According to the docs, you need to check that Options FollowSymLinks is enabled before trying rewrite in a .htaccess. Then, you also have to note that the per-directory prefix is automatically removed, which means a pattern with ^/ never matches anything (I bet this is why your / doesn't work).

So, in your case, first check Options FollowSymLinks and then change the RewriteRule to be something as covener suggested, or my version:

RewriteRule ^$ /?p=110
share|improve this answer
add comment

RewriteRule / wouldn't match a request to / in htaccess. The path you compare against is empty in that case (the prefix is stripped in htaccess rewriterule)

RewriteRule ^$ http://domain.com/?p=110 
share|improve this answer
add comment

Your Answer

 
discard

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.