How can i get my htaccess to work (subdomains)?

Posted by user358994 on Stack Overflow See other posts from Stack Overflow or by user358994
Published on 2010-06-05T02:37:49Z Indexed on 2010/06/05 18:42 UTC
Read the original article Hit count: 122

Filed under:

I'm sorta a noob at these things but I'm trying to make a simple virtual subdomain with .htaccess. I have wildcard enabled and after lots of digging, this is what I've come up with:

rewriteEngine On 
rewriteCond %{HTTP_HOST} !^$ 
rewriteCond %{HTTP_HOST} !^(www\.)?khpedia\.com$ [NC] 
rewriteCond %{HTTP_HOST}<->%{REQUEST_URI} ^(www\.)?([^.]+).*<->/([^/]+) [NC] 
rewriteCond %2<->%3 !^(.*)<->\1$ [NC] 
rewriteRule ^(.+) /%2/$1 [L]

My directory is setup as

-root
--wiki
----index.php
--test

Right now when I travel to wiki.khpedia.com, I get a page not found. When I travel to wiki.khpedia.com/index.php, it travels to wiki.khpedia.com/wiki/index.php. I am somehow also able to access wiki.khpedia.com/test. If it doesnt seem obvious yet, I want to be able to go to wiki.khpedia.com/index.php and see wiki.khpedia.com/wiki/index.php but not in my address bar. Sorry for the text block and thanks for the help.

© Stack Overflow or respective owner

Related posts about .htaccess