Reputation: 119
I have two wordpress sites lying on the same hosting account, they are each in their own subdirectory and have their own database.
-Root
--site1
--site2
Site 1 has 3 domain names site1.dk site1.eu site1.org
Site 2 has 1 domainame site2.com
I would like to point site1.dk, site1.eu, site1.org into the subfolder site1. And site2.com down in the subdirectory site2.
In addition, I want to remove the subfolder name site1 / 2
I have solved site1 with the following htaccess in the root
RewriteEngine On
RewriteCond %{HTTP_HOST} ^site1\.dk$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1 \.dk$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^site1\.eu$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1\.eu$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^site1\.org$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site1\.org$ [NC]
RewriteRule ^site1/(.*)$ http://www.site1.dk/site1/$1 [L,R=301]
RewriteRule ^$ site1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ site1/$1
All the above urls goes in to site1 subfolder and the url look like this site1.dk. Done and ok!
But if i add this to the root htaccess
RewriteCond %{HTTP_HOST} ^site2\.org$ [NC]
RewriteRule ^site2/(.*)$ http://www.site2.dk/site1$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.site2\.org$ [NC]
RewriteRule ^site2/(.*)$ http://www.site2.dk/site2/$1 [L,R=301]
RewriteRule ^$ site2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ site2/$1
Everything falls apart.
I'm not so familiar with htaccess and url rewriting and could use some help.
Thanks in advance
/ / Kasper
Upvotes: 0
Views: 1311
Reputation: 11852
I'd think you'd want to do this with a virtual host, not through .htaccess
. Depending on how your server is set up, you may need to edit apache/conf/extra/httpd-vhosts.conf
directly or work through an abstraction layer in cPanel/Plesk/WHM or something similar.
You shouldn't need an .htaccess
file in your root folder in the example above. If your hosts are set up properly, this shouldn't be accessible to a visitor from the web.
Upvotes: 0