0

I try to redirect a secondary domain towards a main domain, but for a reason URLs containing a directory path aren't redirected (e.g. www.secondaryDomain.com/aDirectory ). This is the section of the .htaccess file where the redirect instructions are (I guess). What is wrong here?

<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress



 RewriteCond %{HTTP_HOST} ^secondaryDomain\.com$ [OR]
   RewriteCond %{HTTP_HOST} ^www\.secondaryDomain\.com$
   RewriteRule (.*) http://mainDomain.com/$1 [R=301,L,QSA]
tje
  • 13
  • 3

1 Answers1

0

The 2nd parameter of RewriteCond is a regular expression, which should be escaped, whereas the 2nd parameter of the RewriteRule is a string, and doesn't have to be and doesn't need the quotes either. I would try changing the last three lines to:

RewriteCond %{HTTP_HOST} ^secondaryDomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.secondaryDomain\.com$
RewriteRule (.*) http://mainDomain.com/$1 [R=301,L,QSA]

Hope this helps.

clmarquart
  • 4,721
  • 1
  • 27
  • 23
  • Thanks you for answering! Although the problem isn't solved (that is, typing www.secondaryDomain.com/aDirectory doesn't redirect) I come closer to having a more correct redirection and indirectly bring me closer to a solution, as I will also edit the code in the question to prevent getting the same answer again. I appreciate your help! – tje Apr 08 '11 at 10:41