Forum Moderators: phranque

Message Too Old, No Replies

Prevent rewrite of sub-domains

         

CNibbana

1:58 am on Aug 5, 2004 (gmt 0)

10+ Year Member



I have my site setup so that every page request is sent to my index.php file and the pages are parsed there, except for those subdirectories I have indentified (forum, pages, images, errors).

RewriteEngine on
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !^/(forum¦pages¦images¦errors)
RewriteCond %{HTTP_HOST} !^http://(.+\.)?domain\.com$
RewriteRule !\.(gif¦jpg¦png¦css¦js)$ %{DOCUMENT_ROOT}/index.php [NC]

Trouble is, my subdomains (sub.domain.com) are also redirecting to the index.php file. Is there a way to provide a blanket exception in the main .htaccess file to prevent subdomains from rewriting to the index.php file?

I have tried what I have above and I have tried placing a blank .htaccess file in each subdomain and neither has worked?

[edited by: jdMorgan at 2:33 am (utc) on Aug. 5, 2004]
[edit reason] Fixed [ code ] formatting to prevent wrapping [/edit]

jdMorgan

2:42 am on Aug 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This modified code will require that the requested domain be either "domain.com" or the subdomain "www.domain.com" in order to invoke the rewrite. No subdomain other than "www" will invoke the rewrite.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(forum¦pages¦images¦errors)
RewriteCond %{HTTP_HOST} ^[b](www\.)?[/b]domain\.com
RewriteRule !\.(gif¦jpg¦png¦css¦js)$ %{DOCUMENT_ROOT}/index.php [L,NC]

Note that a pattern intended to match %{HTTP_HOST} should not contain "http://", and it should not be end-anchored in case a port number is appended by the client, e.g. "www.example.com:80". I'm not sure why you need %{DOCUMENT_ROOT} in your code -- try leaving that out.

Jim

CNibbana

1:18 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



That worked great Jim, thanks!