Forum Moderators: phranque
i'm running blog hosting script which uses .htaccess file to create the subdomains for the users (user.domain.com)
recently i've purchased another domain name and point it to the same location as the first one.
what i want to get is to be able to access all blogs from both domain names (blog.domain1.com = blog.domain2.com)
the current .htacces file is the following:
RewriteEngine On
Options +Followsymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\. [NC]
RewriteCond %{REQUEST_FILENAME}!^.*/images/.*$
RewriteCond %{REQUEST_FILENAME}!^.*/uploads/.*$
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain1\.com(:80)?<>/([^/]*) [NC]
RewriteCond %1<>%3!^(.*)<>\1$ [NC]
RewriteRule ^(.*)$ - [E=BLOGUSER:%1]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^$ /index.php?w=%1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^page([0-9]+)/([^/]+)?$ /index.php?w=%1&page=$1$2 [L]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^profiles/([^/]+)/([^/]+)?$ /profile.php?u=$1$2 [L]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^profiles/?$ /profile.php [L]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^albums/([^/]+)/([^/]+)?$ /album.php?u=$1$2 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/(.*)/(.*)/([^/]+)?$ /archive.php?w=%1&y=$1&m=$2$3 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive\.php/(.*)/(.*)/([^/]+)?$ /archive.php?w=%1&y=$1&m=$2$3 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/(.*)/([^/]+)?$ /archive.php?w=%1&y=$1$2 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive\.php/(.*)/([^/]+)?$ /archive.php?w=%1&y=$1$2 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/([^/]+)?$ /archive.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive\.php/([^/]+)?$ /archive.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends/([^/]+)?$ /friends.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends\.php/([^/]+)?$ /friends.php?w=%1$1 [L]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]+)/friends/page([0-9]+)/([^/]+)?$ /friends.php?w=$1&page=$2$3 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([0-9]+)/([^/]+).html$ /entry.php?w=%1&e_id=$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([0-9]+)/([^/]+)?$ /entry.php?w=%1&e_id=$1$2 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^&([^/]+)?$ /index.php?w=%1&$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([^/]+)/([^/]+)?$ /index.php?w=%1&category=$1$2 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([^/]+)/page([0-9]+)/([^/]+)?$ /index.php?w=%1&category=$1&page=$2$3 [L]
if i change
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain1\.com(:80)?<>/([^/]*) [NC]
into
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain2\.com(:80)?<>/([^/]*) [NC]
everything works fine only for the second domain (e.g. blogname.domain2.com)
if i leave both lines
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain1\.com(:80)?<>/([^/]*) [NC]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain2\.com(:80)?<>/([^/]*) [NC]
the links don't work at all, they redirect to the portal page
is there a string or something which will tell the file to use both domains...something like
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain1\.com(:80),\.domain2\.com(:80)?<>/([^/]*) [NC]
i'm only thinking loudly, probably its nonsense...
anyway, i really want to make this work so any kind of help is appreciated
thanks,
Baze
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain1\.com(:80)?<>/([^/]*) [NC,[b]OR[/b]]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.domain2\.com(:80)?<>/([^/]*) [NC]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.(domain1¦domain2)\.com(:80)?<>/([^/]*) [NC]
You could also use the in-line OR to reduce your per-page rules by half. Just a random example:
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/([^/]+)?$ /archive.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive\.php/([^/]+)?$ /archive.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends/([^/]+)?$ /friends.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends\.php/([^/]+)?$ /friends.php?w=%1$1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^(archive¦friends)(\.php)?/([^/]+)?$ /$1.php?w=%1$3 [L]
Jim