Solved

htaccess file

Posted on 2014-04-23
4
375 Views
Last Modified: 2014-04-23
I am moving domains.  On the old domain I created an htaccess file with the following contents only:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule (.*)$ http://www.new.com/$1 [R=301,L]

Is this correct?  Should I have any other code or text int he file?
0
Comment
Question by:a204801
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Insoftservice earned 500 total points
ID: 40018156
Its correct you could even try this one

RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
0
 

Author Comment

by:a204801
ID: 40018163
Im trying to preserve the existing link structure.  So if they go to

old.com/why/because

they end up on

new.com/why/because

Not to mention, if they go to www.old.com or old.com, they get forwarded to www.new.com
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 40018178
what you want actually .
As your htacces says that it has to redirect to new one
please elaborate your reuirement
0
 

Author Comment

by:a204801
ID: 40018419
I believe I figured out the issue.  I had the DNS host pointing towards the correct spot, but I didn't realize that www, via CNAME, was still pointing towards the old host.  I have rectified the mistake.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 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

11 Experts available now in Live!

Get 1:1 Help Now