Mobile app version of vmapp.org
Login or Join
Lee4591628

: Url redirect in dreamhost without editing htaccess We have a network of sites with an old link to a URL that doesn't exist anymore. We would like to redirect all the traffic to this URL to

@Lee4591628

Posted in: #Dreamhost #Redirects

We have a network of sites with an old link to a URL that doesn't exist anymore. We would like to redirect all the traffic to this URL to the new website, while we correct the old link in all the network sites.

Since we are a student organization, I cannot be sure that whoever will come after me will have the same technological knowledge as me, so I don't want to code the redirect in the .htaccess.

Instead I was wondering if there was another way to do this using the Dreamhost control panel, since we host our site there.

Until now though, I didn't find the way to do a redirect for a single URL, but just for a whole domain.

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Lee4591628

4 Comments

Sorted by latest first Latest Oldest Best

 

@Yeniel560

Let's have a look at the example 1 - Redirect example.com to example.com. The first line tells apache to start the rewrite module. The next line:

The final line describes the action that should be executed:

RewriteRule ^(.*)$ example.com/ [L,R=301]

RewriteCond %{HTTP_HOST} !www.example.com$


specifies that the next rule only fires when the http host (that means the domain of the queried url) is not (- specified with the "!") example.com.
The $ means that the host ends with example - and the result is that all pages from example.com will trigger the following rewrite rule. Combined with the inversive "!" is the result every host that is not example.com will be redirected to this domain.

The next part example.com/ [L,R=301] describes the target of the rewrite rule -this is the "final" used domain name, where contains the content of the (.*).

The next part is also important, since it does the 301 redirect for us automatically: [L,R=301]. L means this is the last rule in this run. After this rewrite the webserver will return a result. The R=301 means that the webserver returns a 301 moved permanently to the requesting browser or search engine.

Redirect visitors to a new site

You have an old website that is accessible under livemnc.com and you have a new website that is accessible under livemnc.in. Copying the content of the old website to the new website is the first step - but what comes after that? You should do a 301 moved permanently redirect from the old domain to the new domain - which is easy and has some advantages:

Search engines will be redirected to the new domain and all related information will be moved to the new domain (but this might take some time).
Google's PageRank â„¢ will be transfered to the new domain, as well as other internal information that is being used to set the position of pages in the search engine result pages (serp's) - like TrustRank .


Create a 301 redirect for all http requests that are going to the old domain.

Example 1 - Redirect from oldexample.com to newexample:
RewriteEngine On
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ newexample.com/ [L,R=301]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ example// [L,R=301]


Explanation of the add trailing slash .htaccess rewrite rule:

The first line tells Apache that this is code for the rewrite engine of the mod_rewrite module of Apache. The 2nd line sets the current directory as page root. But the interesting part is:

RewriteCond %{REQUEST_FILENAME} !-f


makes sure that existing files will not get a slash added. You shouldn't do the same with directories since this would exclude the rewrite behavior for existing directories. The line

RewriteCond %{REQUEST_URI} !example.php


excludes a sample url that should not be rewritten. This is just an example. If you do not have a file or url that should not be rewritten, remove this line. The condition:

RewriteCond %{REQUEST_URI} !(.*)/$

RewriteRule ^(.*)$ example.com// [L,R=301]


does the 301 redirect to the url, with the trailing slash appended. You should replace example.com with your domain

10% popularity Vote Up Vote Down


 

@Annie201

To redirect a domain to another from the panel, you'd head to your Domains > Manage Domains page click "Edit" next to the domain there. There's a redirect option on the next page.

To redirect only a specific page to another domain/url, a PHP redirect is your best alternative to using .htaccess:
wiki.dreamhost.com/PHP_Redirect
Reach us at Support > Contact Support in your panel if you have any trouble!

10% popularity Vote Up Vote Down


 

@Vandalay111

If it is a top level domain, then you could use a domain forwarder from the company your purchased the domain from.

Not familiar with Dreamhost, but from my experience with cpanel, there should be a section with the header domain and under it should be something like redirect.

10% popularity Vote Up Vote Down


 

@Correia994

I think having a file in the location would be a logical place for them to check if they're not aware of re-writing.

old-page.php:

<?php
header("Location: new-page.php", 302);
?>


302 being a Redirect Temporary. Other response codes are listed in at W3C - HTTP1/1 Status Code Definitions.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme