Tag Archives: rewrite

How to Redirect a URL in a Virtual Host

How to Redirect a URL in a Virtual Host | Redirecting a URL in a virtual host is a snap! I’ll show you how. Scenario: you have a server that receives example.com but you want that to redirect to example2.com. First you will want to add this to your /etc/apache2/ports.conf (Debian or Ubuntu) or /etc/httpd/conf/httpd.conf (Red Hat or CentOS) if you have not already: NameVirtualHost

Redirect www to non-www

Redirect www to non-www | How can I redirect my website to go from http://www.example.com to just plain ol’ http://example.com? Use the following rewrite blurb where appropriate for your website. An easy thing to do is to add this to your .htaccess file in your website’s root directory: