alittle tough to explain..

Using a single web hosting account to host multiple sites

alittle tough to explain..

Postby rolyroly » Sat Dec 02, 2006 7:48 am

right now, i had a mod_rewrite code at root level that make sub.domain.com/file.php to fetch from www.domain.com/sub/file.php

Code: Select all
RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.DOMAIN$ [NC]
RewriteCond %1---%{REQUEST_URI} !^(.+)---/\1(/.*)?$
RewriteRule .* /%1%{REQUEST_URI} [QSA,L]


Currently, i had to put the following code in the file .htaccess in every directory in order to enable search engine friendly url for my subdomain.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /goody/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /goody/index.php [L]
</IfModule>


is it possible to setup a single mod_rewrite code at root level to handle all these? what are code to add on to my above .htaccess file at root lvl?
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm

Postby richardk » Sat Dec 02, 2006 3:29 pm

Try:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-d
RewriteRule !^[^/]+/index\.php$ /%1/index.php [QSA,L]

RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteCond %1---%{REQUEST_URI} !^(.+)---/\1(/.*)?$
RewriteRule .* /%1%{REQUEST_URI} [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rolyroly » Sat Dec 02, 2006 7:13 pm

Hi richard,

I got a 500 internal error.
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm

Postby richardk » Sun Dec 03, 2006 2:32 pm

The following works fine for me:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-d
RewriteRule !^[^/]+/index\.php$ /%1/index.php [QSA,L]

RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteCond %1---%{REQUEST_URI} !^(.+)---/\1(/.*)?$
RewriteRule .* /%1%{REQUEST_URI} [QSA,L]


What version of Apache are you using?
What does your error log say?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rolyroly » Sun Dec 03, 2006 7:07 pm

Hi Richard,

I went around moving around the code.

Got it working after i swap the position of the code.

Thanks for your help.
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm

Postby rolyroly » Sun Dec 03, 2006 11:49 pm

Hi Richard,

I had a small problem.

The following file unable to sync from the real subdomain directory properly.

http://subdomain.domain.com/wp-content/ ... /style.css

The original url is http://domain.com/subdomain/wp-content/ ... /style.css

i think it had to do with "-" , "_" .

what code should be change to accept the above symbol?
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm

Postby richardk » Mon Dec 04, 2006 10:45 am

If you've changed it round, what have you got now?

The - character shouldn't be a problem, no characters are ever matched.

What do you mean by unable to sync? A 404 error? Does it go to the index page? Is style.css a real file or does it use mod_rewrite too?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rolyroly » Mon Dec 04, 2006 7:18 pm

Hi richard,

style.css is a real file.

another example, when i try to go http://subdomain.domain.com/wp-login.php , it say file cannot be found.
in actual fact, it is there. It doesn't seem to read it properly from domain.com/subdomain/wp-login.php

My current .htaccess is as follow:

Code: Select all
Options +FollowSymLinks
RewriteEngine On

#sub.domain.com/* to domain.com/sub/*
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.DOMAIN$ [NC]
RewriteCond %1---%{REQUEST_URI} !^(.+)---/\1(/.*)?$
RewriteRule .* /%1%{REQUEST_URI} [QSA,L]

#seo for subdomain
RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} !-d
RewriteRule !^[^/]+/index\.php$ /%1/index.php [QSA,L]
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm

Postby richardk » Tue Dec 05, 2006 8:55 am

Try adding
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$

after
Code: Select all
#seo for subdomain


If that doesn't work go back to using multiple files.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rolyroly » Wed Dec 06, 2006 5:05 am

Hi Richard,

The seo for the file don't work after adding that additional code.
rolyroly
 
Posts: 6
Joined: Sat Jul 08, 2006 9:37 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron