Solved

Htaccess for Domain move

Posted on 2011-03-23
6
370 Views
Last Modified: 2012-05-11
Hello,

 I would like to move my existing site to a new domain. I need a 301 permanent move for all urls to new corresponding urls.


 www.old-domain.com/forum/{some-url}

under folder all urls will be directed to

 www.new-domain.com/{some-url}


AND

www.old-domain.com/portal/{some-url}

to

www.new-domain.com/portal/{some-url}



How should we write that htaccess file to achive this result?
0
Comment
Question by:mescalin
6 Comments
 
LVL 9

Expert Comment

by:fcontrepois
ID: 35202456
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 35202799
Just place the .htaccess file inside the directory of  forum of olddomain (  www.old-domain.com/forum/ ) with the following contents.

Redirect 301 /forum  www.new-domain.com/{some-url}

For www.old-domain.com/portal/{some-url} , place .htaccess with the following content inside the directory portal.

Redirect 301 /portal www.new-domain.com/portal/{some-url}

Let me know if you face any difficulty.
0
 

Author Comment

by:mescalin
ID: 35203621
Hello,

 Thank you for the reply but {some url} part is also important because i have 200k pages and when user hits any url in the old domain it should write exact same url for the new domain. I wont write {some url} it should generate it. is it possible?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 11

Accepted Solution

by:
Murfur earned 500 total points
ID: 35205674
Assuming the folders and files are as they were on the old server then this should transfer every request to the new server:

RewriteEngine On
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]

Open in new window

0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 35212169
Sorry for my late reply. I was away. Glad to know the rewrite rule works fine for you.

Cheers!!!
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35212577

RewriteEngine On
RewriteRule ^www.old-domain.com/(.*)$ www.new-domain/$1 [R=301,L]

Open in new window

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now