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.

up vote 1 down vote accepted

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:

http://wiki.dreamhost.com/PHP_Redirect

Reach us at Support > Contact Support in your panel if you have any trouble!

  • so it's not possible without editing the .htaccess... – Bakaburg Aug 4 '12 at 17:32

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.

  • there are two problems with this. This location doesn't exist anymore, and then the url was written in a very old fashion way, pointing to an html file, so no php. – Bakaburg Aug 3 '12 at 17:15
  • @Bakaburg You could create the file (old-file.html ), then add .html to the types that are parsed as PHP. – choster Aug 3 '12 at 18:58

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.

  • it's just a page, not the whole domain – Bakaburg Aug 4 '12 at 17:32

Let's have a look at the example 1 - Redirect example.com to www.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 ^(.*)$ www.example.com/$1 [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 "!") www.example.com.

The $ means that the host ends with www.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 www.example.com will be redirected to this domain.

The next part www.example.com/$1 [L,R=301] describes the target of the rewrite rule -this is the "final" used domain name, where $1 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 www.newexample:

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

RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !example.php
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ example/$1/ [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/$1/ [L,R=301]

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

  • This does not answers the OPs question. It looks like an attempt at a linking opportunity. Two other spam answers where deleted. This one was salvaged because there is some value here. The OP was asking specifically if there was a way to use the dreamhost control panel and avoid using .Htaccess. Can you address this? Cheers!! – closetnoc Aug 11 '17 at 5:52

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.