Mobile app version of vmapp.org
Login or Join
Alves908

: Trouble redirecting sub.example.com to sub.example.com/directory/ I have a website set up at example.com/directory/ currently. /directory/ is set up to display different contents depending on the subdomain,

@Alves908

Posted in: #Apache #HttpdConf

I have a website set up at example.com/directory/ currently. /directory/ is set up to display different contents depending on the subdomain, that part is working fine. I'm having trouble editing my httpd.conf file to work correctly though.

Obviously I can only set up my A records for sub.example.com to point to example.com and not example.com/directory/ so I've set up some rules in my httpd to get around this, but they don't seem to be working. This is what I've got so far:

RewriteCond %{HTTP_HOST} ^sub1.example.com$ [NC]
RewriteRule ^((?!folder).*)$ /directory/ [NC,L]

RewriteCond %{HTTP_HOST} ^sub2.example.com$ [NC]
RewriteRule ^((?!folder).*)$ /directory/ [NC,L]


What seems to be happening though is those rules just direct each subdomain to example.com/directory and drop the subdomain completely. I'm a little lost as to what I need to change here, I'm not very well versed in Apache.

I know this should be simple, but I can't seem to find any documentation that is straightforward enough for me to understand, does anybody have any pointers?

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves908

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme