Htaccess Wildcard Subdomains?

You probably need to exclude the index. Php from your rule: RewriteCond %{HTTP_HOST}! ^www\.

Example\. Com$ NC RewriteCond %{HTTP_HOST} ^(www\. )?(a-z0-9-+)\.

Example\. Com$ NC RewriteRule! ^index\.

Php($|/) index. Php/accounts/%2%{REQUEST_URI} PT,L.

Thanks, I used something else (-f and -d), but this works as well, so I'm going to file it away for future reference. – Zahymaka Jun 29 '09 at 21:48.

This is an adaptation of the code I use to redirect subdomains on my own site. I make no claims to it being best practice but it works; RewriteCond %{HTTP_HOST} ^(.*)\. Com$ NC RewriteCond %1!

^(www)\. Example$ NC RewriteRule ^. *$ example.com/index.php/accounts/%1/ R=301,L.

This works, but I don't want to redirect users on the site. Thanks all the same. – Zahymaka Jun 29 '09 at 18:27 I'm not in a position to test it right now, but would it not work just the same by replacing R=301,L with PT,L?

– MatW Jun 29 '09 at 18:40.

Try changing your RewriteRule to RewriteRule ^/(.*)$ /index. Php/accounts/%1/$1 PT That will rewrite the URL to one that includes the subdomain and the original request URI. EDIT: maybe it needs to be RewriteRule ^(.*)$ /index.

Php/accounts/%1/$1 PT as mentioned in the comments.

I tried this but it doesn't appear to be firing, even when I change index. Php to something else. – Zahymaka Jun 29 '09 at 18:32 Oh... maybe you need to use the pattern ^(.*)$ (no slash) when it's in .htaccess.(For what it's worth, I would recommend putting these directives in the main server configuration file if you can.) – David Zaslavsky Jun 29 '09 at 19:47 See below.

Thanks for all the help! – Zahymaka Jun 29 '09 at 21:48.

At the same time I'm trying to use subdomains. If a user hits candybar. Example.com I want the page test.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions