• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

[APACHE] .htaccess subdomain redirect not working


+SpeedyTheSnail    1,287

Hello all!


After GoDaddy gave me the finger when my Wordpress site was hacked and a trojan was uploaded (apparently basic web hosting SLA doesn't include restoration to their previous backups without a nice fee), I decided to use my own VPS with AWS Lightsail (It's cheaper and easier to set up compared to AWS EC2).


Anyway, I am trying to redirect the subdomain mail.domain.com to domain.com/mail (with URL masking, showing only mail.domain.com/pages), but the configuration is not working.

Below is a copy of my .htaccess file:

# Enable .htaccess files
RewriteEngine on
RewriteBase /
# Redirect mail.domain.com to domain.com/mail/, as well as any subdomain.domain.com to domain.com/subdomain
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain\.com/%1 [L,R]

Also, I have set AllowAccess all in my httpd.conf file.

I am using Amazon's AMI, which apparently is based off CentOS.


Thanks for the help all, I have tried several different ways from different sites and nothing works. I still do not completely understand this as I never had a need to do this until now.

Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Seahorsepip    610

Redirecting mail.domain.com to domain.com/mail/ is a very strange thing to do :s


Since in most cases mail.domain.com is actually a redirect to domain.com/mail/ which means the pages should already be accessible at domain.com/mail :/

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.