Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Search Engine Optimization (SEO) (http://www.go4expert.com/forums/seo-forum/)
-   -   .htaccess redirect for subdomains (http://www.go4expert.com/forums/htaccess-redirect-subdomains-t2503/)

sinasylum 10Jan2007 11:01

.htaccess redirect for subdomains
 
I am trying to make my site do this...

when cpanel creates a sub-domain it just puts the root folder of the sub-domain as a sub-folder of the primary domain on the account. so http://sub.domain.com would also be http://www.domain.com/sub/.

but I want to make it where two things happen... if someone accesses a sub-domain with www, it rewrites the subdomain url without www, and also when someone accesses my subdomain as a sub-folder of the root domain, it also rewrites that and directs the user to the subdomain url.

Anyone know how to do both or either? thanks for all feedback!

regards,

the G4E newbie

shabbir 10Jan2007 11:36

Re: .htaccess redirect for subdomains
 
Quote:

Originally Posted by sinasylum
but I want to make it where two things happen... if someone accesses a sub-domain with www, it rewrites the subdomain url without www,

Use the following
Code:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC]
RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301]

Quote:

Originally Posted by sinasylum
and also when someone accesses my subdomain as a sub-folder of the root domain, it also rewrites that and directs the user to the subdomain url.

Use a hardcoded one for the domain and for the files have a wildcard.

sinasylum 10Jan2007 13:34

Re: .htaccess redirect for subdomains
 
thank you. i will give it a shot and see how things go.

csgraduate 11Aug2007 05:24

Re: .htaccess redirect for subdomains
 
Hi,
I am trying to redirect
subdomain.mysite.com to mysite.com/index.php?id=subdomain passively
so as the address in browser remains as subdomain.mysite.com .

Below is the code from my .htaccess file.

RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{QUERY_STRING} !^id=.
RewriteRule (.*) /index.php?id=%1 [L]


I don't know why it's still not redirecting as wanted.

Any Ideas ?

Thanks

shabbir 11Aug2007 10:03

Re: .htaccess redirect for subdomains
 
For Redirect the address bar will not remain as it is. It will change in the address bar.

csgraduate 11Aug2007 20:59

Re: .htaccess redirect for subdomains
 
Yes , but its not even redirecting.


All times are GMT +5.5. The time now is 18:24.