1

I have two domains being served from the same WP install. edit: not multi-site

In wp-config.php I have define('WP_SITEURL', "http://$hostname/wordpress"); etc.

The two domains will have similar content, but we want to be able to have them at the same path, e.g. domain1.com/about-us and domain2.com/about-us.

I've therefore set up these two pages \dom1\about-us and \dom2\about-us, and in my .htaccess I have:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} dom1 [NC]
RewriteRule ^((about\-us|etc).*) /dom1/$1 [NC,QSA,L]

RewriteCond %{HTTP_HOST} dom2 [NC]
RewriteRule ^((about\-us|etc).*) /dom2/$1 [NC,QSA,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I get (edit: WordPress) 404 error pages for the above URLs. I've added print_r($_SERVER); in my 404 template and get the following (simplified output).

Array
(
[REQUEST_URI] => /about-us/
[REDIRECT_REDIRECT_STATUS] => 200
[REDIRECT_STATUS] => 200
[HTTP_HOST] => dom1.dev
[SERVER_NAME] => dom1.dev
[REDIRECT_URL] => /dom1/about-us/
[QUERY_STRING] => 
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
...
)

Doesn't that mean that the rewrite has worked, but WP is not using it?

Many thanks in advance.

3
  • If you are running multisite, then this shouldn't be an issue? Since each domain counts as its own site basically, then you should be able to have /about-us without needing to do anything special.
    – Shawn
    Nov 22, 2013 at 16:51
  • I'm not using multisite.
    – jezmck
    Nov 22, 2013 at 20:07
  • Check your {HTTP_HOST} data. It should be dom1.dev instead dom1 RewriteCond %{HTTP_HOST} dom1.dev$ [NC]
    – Manish
    Nov 25, 2013 at 17:18

1 Answer 1

1
RewriteCond %{HTTP_HOST} dom1 [NC]
RewriteRule ^((about\-us|etc).*) /dom1/$1 [NC,QSA,L]

Your rewrite rule includes the L parameter, which makes it stop processing rewrites. So WordPress's rules to redirect to index.php likely never come into effect. Which means WordPress is not even being run here. The 404 is likely from the webserver saying that the file at /dom1/about-us does not exist.

1
  • [L] doesn't work quite like that actually. The error pages are from WordPress.
    – jezmck
    Nov 22, 2013 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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