Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

redirect, rewrite, alias -  which one?

Posted on 2011-05-02
9
Medium Priority
?
157 Views
Last Modified: 2012-11-30
hello.  I have a need to redirect a site, say www.somesite.com/somedir to www.somesite.org/somedir

I have a rewrite rule in place now to get the users from http to https
I also have a redirect in place now to get the users to the write somedir if they do not add it.
These work.

Various iterations trying to get them going from one subdomain to another is not working.  What am I missing?  thanks.
0
Comment
Question by:bongios
9 Comments
 
LVL 4

Expert Comment

by:bigg_oil
ID: 35508602
you must edit your httpd.conf file

example
Listen 80
NameVirtualHost *

<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>

<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>

Open in new window


also setup a CName in dns records

http://content.websitegear.com/article/subdomain_setup.htm
0
 
LVL 10

Expert Comment

by:Tyler Laczko
ID: 35508615
you can use a JS or PHP script to do it.

<?php
header("Location: othersite.org.com");
?>
0
 

Author Comment

by:bongios
ID: 35508681
I have edited the httpd.conf but as I said, the results were not as expected.
I do not have access to dns records, but will suggest that do to the admin there.

Where would the JS or PHP script be placed for it to run?

thanks much all.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 9

Expert Comment

by:Erdinç Güngör Çorbacı
ID: 35509402
Best way of doing this without losing Pagerank (if its important) is doing a 301 redirect.

Write me down if you need more help... bb
0
 

Author Comment

by:bongios
ID: 35511618
Erdincgc,
I'd like more info on this, please.
thanks..
0
 
LVL 9

Accepted Solution

by:
Erdinç Güngör Çorbacı earned 2000 total points
ID: 35511800
You can use 3 methods for 301 redirection

- Using the PHP header() function if your webserver supports PHP.
- Using the mod_rewrite functionality of Apache servers.
- Using built-in forwarding if your host provides it.

For first one ;

add this to the beginnings of the pages at your old domain.  (better include from a file )

<?php
 if(stristr($_SERVER["HTTP_HOST"], 'www')){
  header("HTTP/1.1 301 Moved Permanently");
  header("Location: http://mynewwebsite.com/" . $_SERVER["REQUEST_URI"]);
  exit();
  }
?>

Open in new window


code above sends the visitor from

http://www.myoldsite.com/detail.php
to
http://www.mynewsite.com/detail.php

as you can see not just domain but either page data is being used from url.
And exit() is important to make sure the rest of code is not executed before redirection.

Second way is using htaccess. -i prefer this one-

put lines below in a file named .htaccess (cant rename to this in windows rename after ftp if needed)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^myoldsite\.com [nc]
RewriteRule (.*) http://www.mynewsite.com/$1 [R=301,L]

if you need to carry Query Strings you can use QSA in [] at end of last line.

For more diggin you may consider taking a look at these pages ;

http://www.google.com/support/webmasters/bin/answer.py?hlrm=tr&answer=93633
http://www.bigoakinc.com/seo-articles/301-direct-Google.php

good luck :)

BTW : To test any 301 redirection, make sure you clear your browser's cache first! Otherwise, you won't see if it worked or not.
0
 
LVL 9

Expert Comment

by:Erdinç Güngör Çorbacı
ID: 35734396
Hi! Do you have any other  questions upon my last answer?
0
 

Author Comment

by:bongios
ID: 35786965
have not yet implemented -- will try the 301 this weekend.  Thanks so much!
0
 

Author Closing Comment

by:bongios
ID: 38648198
I apologize for not awarding the solution. Extreme oversight on my part.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question