OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

.htaccess redirect for URL with parameters does not work

  • Thread starter Thread starter PatInParis
  • Start date Start date
P

PatInParis

Guest
In the following .htaccess, redirecting oldsite.com to newsite.com works fine. But I also want to redirect URLs with parameters from the old site and this does not work:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page_id=4$
RewriteRule http://newsite.com/about/ [QSD,R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite.com$
RewriteRule (.*)$ http://newsite.com/$1 [R=301,L]
</IfModule>

The URL "oldsite.com/?page_id=4" redirects to "newsite.com/?page_id=4" and not to "newsite.com/about/". The .htaccess file on newsite.com is the usual WordPress with nothing added. What am I doing wrong?
<p>In the following .htaccess, redirecting oldsite.com to newsite.com works fine. But I also want to redirect URLs with parameters from the old site and this does not work:</p>
<pre><code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page_id=4$
RewriteRule http://newsite.com/about/ [QSD,R=301,L]
RewriteCond %{HTTP_HOST} ^oldsite.com$
RewriteRule (.*)$ http://newsite.com/$1 [R=301,L]
</IfModule>
</code></pre>
<p>The URL "oldsite.com/?page_id=4" redirects to "newsite.com/?page_id=4" and not to "newsite.com/about/". The .htaccess file on newsite.com is the usual WordPress with nothing added. What am I doing wrong?</p>
Continue reading...
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top