LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-10-2013, 08:06 PM   #1
MarkToronto
LQ Newbie
 
Registered: May 2013
Posts: 1

Rep: Reputation: Disabled
Creating 301 Permanent Redirect to a domain with same docroot as old domain.


Hello, this is my first post here. I did search the forums trying to find an answer, but nothing seemed to allay my fears of what I am about to do.

I am attempting to rebrand my sister's website to a new brand new domain name. But there is only the one docroot with all the pages. I want to create 301 redirects for each page to the new domain, but the problem is that I think if I change the .htaccess file in the docroot to redirect
(say /home/index.php to
https://www.newdomain.com/home/index.php )
then that would send the site into weird a loop since it would just point back at the same docroot.

So.... My thought is that I need to create a brand new docroot folder with an .htaccess file containing all of my 301 redirects to the pages on the new domain. I will point the old website domain at that new docroot, and I will point the new domain at the old docroot.

Does that sound like the right approach?

All of the directory structure and pages under the docroot are the same as the old site. The site in question is an OpenCart site (PHP pages with parameters on the URLs).

So URLs are either like
https://www.olddomain.com/CategoryName
or
https://www.olddomain.com/index.php?route=account/login

My ultimate goal is to tell all search engines that the domain has changed permanently, and to also redirect the customers to the new store (hopefully to the same page they were trying to hit from Google). And hopefully not loose all the search engine stats accumulated by Google.

Is the RedirectPermanent the best directive for this?

Thanks for any help you can give,
Mark
 
Old 05-15-2013, 03:35 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,484

Rep: Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556Reputation: 1556
If your files/folder structure is going to remain identical then set your site up so that the new domain works, then add the following to your apache config either in the conf file for the new domain or as a separate vHost:

Code:
<VirtualHost your.server.ip.here:80>
  ServerName www.olddomain.com
  ServerAlias olddomain.com
  RedirectMatch 301 (.*) http://www.newdomain.com$1
</VirtualHost>
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub domain Redirect adam_1784 Linux - Software 2 01-16-2012 12:01 PM
redirect https://www.domain.com to https://domain.com decenter Linux - Server 4 09-13-2011 10:05 AM
[SOLVED] creating domain form vadddomain-domain doesnot exsist centos123 Linux - Server 1 05-07-2011 01:53 AM
IPtables - block subdomains (a.domain.com, b.domain.com, c.domain.com,...) benjalien Linux - Networking 6 06-24-2009 07:03 AM
redirect user.domain.com to www.domain.com/user macadam Linux - Newbie 2 05-15-2008 01:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration