• 0

[APACHE] .htaccess subdomain redirect not working


Question

SpeedyTheSnail

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.

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Seahorsepip

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 :/

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By News Staff
      Save 95% off the Complete Big Data eBook & Video Course Bundle
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where for only a limited time you can save 95% off the Complete Big Data eBook & Video Course Bundle. Master Big Data and increase business efficiency with 5 e books + over 23 hours of content on Apache, Spark, Hadoop, and more.



      This deal consists of the following courses:

      Practical Big Data Analytics [eBook]
      Get Command of Your Organizational Big Data Using the Power of Data Science & Analytics Data Stream Development with Apache Spark, Kafka, & Spring Boot [Video]
      Architect & Implement an End-to-End Data Streaming Pipeline Apache Kafka Series: Kafka Streams for Data Processing [Video]
      Learn the Kafka Streams API with Hands-On Examples Apache Kafka Series: Kafka Connect Hands-On Learning [Video]
      Learn How to Source Twitter Data, Store in Apache Kafka Topics, & Sink in ElasticSearch and PostgreSQL Scala & Spark for Big Data Analytics [eBook]
      Harness the Power of Scala to Program Spark & Analyze Tons of Data in a Blink of an Eye Real Time Streaming Using Apache Spark Streaming [Video]
      Analyze Data in Real-Time Using the Apache Spark Streaming API Hands-On Data Warehousing with Azure Data Factory [eBook]
      Leverage the Power of Microsoft Azure Data Factory v2 to Build Hybrid Data Solutions Big Data Analytics with SAS [eBook]
      Leverage the Capabilities of SAS to Process & Analyze Big Data Big Data Analytics with Hadoop 3 [eBook]
      Build Highly Effective Analytics Solutions to Gain Valuable Insight Into Your Big Data Master Big Data Ingestion & Analytics with Flume, Sqoop, Hive and Spark [Video]
      Gain Comprehensive Insights Into Big Data Ingestion & Analytics Good to know
      Length of time users can access courses: Lifetime Updates included Redemption deadline: redeem your code within 30 days of purchase For full details, terms, and instructor info for the above courses, click here.

      What's the benefit?
      This Complete Big Data eBook & Video Course Bundle normally costs $698, but you can pick this up for just $29.99 for a limited time, that's a saving of $668.01 (95%) off the normal price!

      >> Get this deal, or learn more about it here <<
      See all discounted Online Courses on offer. This is a time-limited deal.
      Get $1 credit for every $25 spent · Give $10, Get $10 · 10% off for first-time buyers.

      Not for you?
      If this offer doesn't interest you, why not check out the following offers:

      The Nintendo Gaming Bundle Giveaway 20% off Ivacy VPN subscription with coupon code IVACY20 NordVPN subscription at up to 68% off for a 2 year plan Private Internet Access VPN subscription at up to 71% off Unlocator VPN or SmartDNS unblock Geoblock with 7-day free trial Disable Sponsored posts · Other recent deals · Preferred partner software

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs.

    • By News Staff
      This Complete Machine Learning A to Z Bundle was $891 - now only $35
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store where for only a limited time you can save 96% off this Complete Machine Learning A to Z Bundle. The 30-hour track to becoming proficient with today and tomorrow's most important technology.



      What's the deal?
      This bundle consists of the following courses:

      Building Chatbots with Google DialogFlow
      Learn About Google's Answer to Amazon Lex Building Chatbots with Amazon Lex
      Learn About Voice & Chatbots for Slack, Facebook, & More Building Voice Apps Using Amazon Alexa
      Alexa Skills for Echo & Other Amazon Devices An Easy Introduction to AI & Deep Learning
      Get Your Feet Wet with the Backbone to Siri, Self-Driving Cars & More An Easy Introduction to Machine Learning Using Scikit-Learn
      Dive Into Automated Decision-Making with Python's Scikit-Learn Learn By Example: Apache MXNet
      Build Fast & Flexible Machine Learning Apps Once You Master This Intuitive Framework Learn By Example: PyTorch
      Explore & Create the Building Blocks That Power Today's AI with PyTorch Learn By Example: Spark Streaming 2.x
      Handle Continuous Data Like a Pro as You Learn From Real-World Examples Learn By Example: Spark 2.x
      Come to Grips with Spark & Pull Valuable Insights from Your Dat Good to know
      Length of time users can access after purchase: lifetime Certification of completion included Redemption deadline: redeem your code within 30 days of purchase For a full description, specs, and instructor info please click here.

      What's the benefit?
      This Complete Machine Learning A to Z Bundle normally costs* $891 but it can be yours for just $35, that's a saving of $856 (96%)!

      >> Get this deal, or learn more about it here <<
      See all Online Courses on offer. This is a time-limited deal.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      Check out our recent deals here or on the Neowin Deals site. For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerces privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerces own determination of retail pricing.

    • By News Staff
      Get this 12-course Complete Python Data Science Bundle for only $37
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where for only a limited time, you can save 96% off this Complete Python Data Science Bundle. Solve Today's Data Problems & Create AI Innovations with 35+ Hours of Training in Python, Spark & More.



      What's the deal?
      This deal consists of the following courses:

      Learn By Example: Pandas
      Complete Your Data Science Toolbox with this Essential Python Library Learn By Example: NumPy
      Start Working with Multidimensional Data as You Dive Into This Python Library Learn By Example: Seaborn
      Go From Mounds of Data to Detailed Insights Using This Powerful Visualization Tool Learn By Example: Matplotlib
      Build Professional Graphs & Plots with this Essential Visualization Tool Learn By Example: Spark 2.x
      Come to Grips with Spark & Pull Valuable Insights from Your Data Learn By Example: Plotly
      Create Insightful Charts & Graphs with Minimal Programming Know-How Learn By Example: Spark Streaming 2.x
      Handle Continuous Data Like a Pro as You Learn From Real-World Examples Learn By Example: PyTorch
      Explore & Create the Building Blocks That Power Today's AI with PyTorch Learn By Example: Apache MXNet
      Build Fast & Flexible Machine Learning Apps Once You Master This Intuitive Framework An Easy Introduction to Python
      Become a Python Programmer in Just a Few Hours An Easy Introduction To Machine Learning Using Scikit-Learn
      Dive Into Automated Decision-Making with Python's Scikit-Learn An Easy Introduction To AI And Deep Learning
      Get Your Feet Wet with the Backbone to Siri, Self-Driving Cars & More Good to know
      Length of time users can access this course: lifetime Certificate of completion not included Redemption deadline: redeem your code within 30 days of purchase For full details, terms, and instructor info for the above courses, click here.

      What's the benefit?
      This Complete Python Data Science Bundle normally costs $1,189.98, but you can pick this up for just $37 for a limited time, that's a saving of $1152.98 off the normal price!

      >> Learn more or Purchase now <<
      See all discounted Online Courses on offer. This is a time-limited deal.

      Save even more!
      Stick with Neowin Deals and earn credit or even deeper discounts.

      For every $25 spent, you get $1 credit added to your Neowin Deals account. Refer the deal for $10 credit via social media or email and if it results in a purchase of at least $10, you'll get $10 credit added to your account. 10% off for first-time buyers: be sure not to dismiss the popup offer to subscribe to email updates on the deals page in order to profit! Not for you?
      If this offer doesn't interest you, why not check out our giveaways on the Neowin Deals website? There's also a bunch of freebies you can check out here.

      Miscellany and the fine print!
      In some cases, such as with Online Courses, a store credit refund within 15 days of purchase is possible if you are unhappy with it; this does not apply to all deals, so please do check the terms on the page before making a purchase.

      Check our other recent deals, before they expire, or our preferred partner software.

      How can I disable these posts? Click here.

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerces privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs. *Values or percentages mentioned above are subject to StackCommerces own determination of retail pricing.

    • By News Staff
      Get your Back-end Performance eBook (a $29 Value) for free - offer expires tomorrow
      by Steven Parker

      Technology may allow us to “go bigger”, but maybe not necessarily be better when it comes to performance. Claim your complimentary copy (worth $29) free, before the offer expires tomorrow.



      What's it about?
      Servers and Internet connections are getting more sophisticated, and as a result, we feel the need to keep filling them. However, this isn’t the time to become lazy. This is the time to utilize the amazing tools that are available for making websites faster, and to learn how to improve user experience and satisfaction.



      This is a practical collection of tutorials on back-end website performance for web developers. It’s packed with useful, real world hints and tips that you can use on your sites today. It contains:

      How to Optimize MySQL: Indexes, Slow Queries, Configuration by Bruno Škvorc How to Read Big Files with PHP (Without Killing Your Server) by Chris Pitt WordPress Optimization by Tonino Jankov HTTP/2: Background, Performance Benefits and Implementations by Tonino Jankov Apache vs Nginx Performance: Optimization Techniquesby Tonino Jankov An In-depth Walkthrough of Supercharging Apps with Blackfire by Reza Lavaryan How to Boost Your Server Performance with Varnish by Tonino Jankov How to Process Server Logs by Daniel Berman How to get it
      Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last!

      >> Back-end Performance ($29 Value) for free <<
      Offered by SitePoint, view their other free resources.
      Limited time offer, must end tomorrow, October 17

      Not for you?
      That's OK, there are other free eBooks on offer you can check out here, but be aware that these are all time-limited offers. If you are uncomfortable sharing your details with a third-party sponsor, we understand.

      Or via our preferred partner, you can Save 58% off a 2-year subscription to Private Internet Access. Get it for the equivalent of just $2.91 a month!

      How can I disable these posts? Click here.

      Disclosure: A valid email address is required to fulfill your request. Complete and verifiable information is required in order to receive this offer. By submitting a request, your information is subject to TradePub.coms Privacy Policy.

    • By News Staff
      Get some Back-end Performance ($29 Value) completely free until next week
      by Steven Parker

      Technology may allow us to “go bigger”, but maybe not necessarily be better when it comes to performance. Claim your complimentary copy (worth $29) free, before the offer expires next week.



      What's it about?
      Servers and Internet connections are getting more sophisticated, and as a result, we feel the need to keep filling them. However, this isn’t the time to become lazy. This is the time to utilize the amazing tools that are available for making websites faster, and to learn how to improve user experience and satisfaction.



      This is a practical collection of tutorials on back-end website performance for web developers. It’s packed with useful, real world hints and tips that you can use on your sites today. It contains:

      How to Optimize MySQL: Indexes, Slow Queries, Configuration by Bruno Škvorc How to Read Big Files with PHP (Without Killing Your Server) by Chris Pitt WordPress Optimization by Tonino Jankov HTTP/2: Background, Performance Benefits and Implementations by Tonino Jankov Apache vs Nginx Performance: Optimization Techniquesby Tonino Jankov An In-depth Walkthrough of Supercharging Apps with Blackfire by Reza Lavaryan How to Boost Your Server Performance with Varnish by Tonino Jankov How to Process Server Logs by Daniel Berman How to get it
      Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last!

      >> Back-end Performance ($29 Value) for free <<
      Offered by SitePoint, view their other free resources.
      Limited time offer, must end October 17

      Not for you?
      That's OK, there are other free eBooks on offer you can check out here, but be aware that these are all time-limited offers. If you are uncomfortable sharing your details with a third-party sponsor, we understand.

      Or via our preferred partner, you can Save 58% off a 2-year subscription to Private Internet Access. Get it for the equivalent of just $2.91 a month!

      How can I disable these posts? Click here.

      Disclosure: A valid email address is required to fulfill your request. Complete and verifiable information is required in order to receive this offer. By submitting a request, your information is subject to TradePub.coms Privacy Policy.