2

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.

1

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
1

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 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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