How to redirect from to

I am using the following code in my httpd.conf for redirections:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

But, it ends up redirecting to

I want all the following URLs to redirect to

This should do it. The problem is that it looks pretty much like what you already have. When you type in your browser, does it work? Or does it redirect to somewhere else?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteRule ^(.*)$$1 [R=permanent,L]

Redirect to and vice versa, You may want to Redirect to or to Find the htaccess rules you can use to do  Creating Your Own Website was Never That Easy. Come and Check it Out! suggests

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*)$1 [R=301,L]

How to redirect from to, This should do it. The problem is that it looks pretty much like what you already have. When you type in your browser, does it  Search Domain Availability & Get A Domain Today. Or Transfer Your Website Automatically. We Power More Than 1.2 Million Websites Around The Globe.

RewriteEngine On

# Redirect ANY non-www request to https and www
RewriteCond %{HTTP_HOST} !^(www.\.domain\.com)?$

RewriteRule (.*)$1 [R=301,L]

# Redirect ANY HTTP request to https and www
RewriteCond %{SERVER_PORT} !443

RewriteRule (.*)$1 [R=301,L] 

Redirecting Your Domain to www or non-www URL, In this article we explain how to redirect your domain to either the www or non-​www version of it's URL. Creating Your Own Website was Never That Easy. Come and Check it Out!

for SSL Virtual host use the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com
RewriteRule ^(.*)$$1 [R=301,L]

Full Example below:

<VirtualHost *:443>
    DocumentRoot "/var/www/html/yourdomain"
    ServerAlias *
    ErrorLog "logs/yourdomain-error_log"
    CustomLog "logs/yourdomain-access_log" common
    ErrorDocument 404 /index.php
    <Directory "/var/www/html/yourdomain">
        Options FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/yourdomain/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/yourdomain/chain.pem
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com
    RewriteRule ^(.*)$$1 [R=301,L]

What is the process to redirect to , Update .htaccess with 301 canonical redirects data: > RewriteEngine On RewriteCond %{HTTP_HOST} !^$ [NC] RewriteRule ^(. In the left pane, click on.htaccess Editor. Select the domain from the dropdown and then a directory and then click on Use Direct Editor. Add one of the following code snippets into your.htaccess file (based on what you want to do.

[SOLVED] need to redirect http://<domain>.com to http://www , We do this on our Apache webserver but I don't know how to do it on a Windows platform. I need to re-direct the url http://<domain>.com to http://www.<domain>. In this documentation, we can check how to redirect to and redirect to We can do this by adding the rewrite rule in the.htaccess file. (It is also possible to do the same by using cPanel Redirect tool. More details of that method is available here)

How to redirect to (or reverse), If you are on an Apache webserver, you can use mod_rewrite in order to redirect all traffic that goes to the www.domain to the "non www" domain. (If you want it  Changing an existing domain or subdomain to redirect Navigate to the Manage Domains page. The Manage Domains page opens. Click the Edit button located to the right of the domain/subdomain under the 'Web Hosting' column. redirects to, were redirecting requests from to The domain that's not redirecting is "". So, The Forward Domain Name is easily task for the enable domain redirection to the another or different website by the use of the CPanel from the Domain or Web hosting providers. So Enjoy friends and if you have any doubt then let me know by comment below. Watch the below Video for How to Redirect/Forward Domain Name to a different Website.

  • It works when I go to, but it does not work when I go to or
  • When you to go it shows your website just fine, but if you go to it does the weird broken URL thing. Did I correctly interpret what you said?
  • Actually, this only happens in Chrome. In Firefox, goes to How come there is an extra slash at the end of the URL?
  • Ah! The extra slash comes from the (.*) match. It matches the opening slash. I've edited my answer above to compensate.
  • Can you provide the domain that you are doing this on so I can see the HTTP headers that are being sent/received?