Apache Rewrite Rules
Apache’s rewrite rules allow you to change an incoming request for different reasons- perhaps because a page moved or your site layout changed. Here are some examples of how you can use rewrite rules in your site.
After you make any changes to your apache configuration, be sure to restart apache. On CentOS, you do this with
sudo /sbin/service httpd restart
HTTP_HOST Rewriting
For various reasons you may want to redirect all of your traffic to a single subdomain. For example, you might want to send all traffic for www.mydomain.com to mydomain.com. To do that, add this to your apache configuration. You’ll usually want to put it inside the VirtualHost context.
RewriteEngine On # You might already have this line
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
