[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

301 redirect

Posted on 2011-10-05
13
Medium Priority
?
389 Views
Last Modified: 2012-06-21
Hi E's, I want move a entire site do another server and another domain, and I have some doubts about the redirect.
I read in google sitemaps, that I have to inform in file .htaccess about that move, the problem is I don't understand that language.

In practice, I have 120 pages, and each page is in a different folder, like:
example.com/folder1/index.htm
example.com/folder2/index.htm
example.com/folder3/index.htm
etc....

and in the new domain will appear in this way:
newdomain.com/folder1/index.php
newdomain.com/folder2/index.php
newdomain.com/folder3/index.php
etc....
note: the files .htm will transform to .php files

What I have to do in .htaccess to made the correct 301 redirect?

The best regards, JC
0
Comment
Question by:Pedro Chagas
  • 6
  • 5
  • 2
13 Comments
 
LVL 24

Expert Comment

by:mankowitz
ID: 36916518
If you can write to .htaccess, include this

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

For more info, see http://www.webconfs.com/how-to-redirect-a-webpage.php
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36916863
Hi, I'm confused!
I thing in your example I have to create a .htaccess file for all folder where is the file index.htm, correct?

Regards, JC
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 36916937
you should only have to create the .htaccess folder in the top level folder where you want it to work. it should automatically cascade down to all subfolders. Also, if you want to move an entire tree, you probably will want to put this into httpd.conf, if you have access to that.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 600 total points
ID: 36918433
I think I might do it in PHP.  Presumably all of your scripts start with a common include() script - something that starts the session, connects the data base, etc.  In that script on the old server, you might take the value of $_SERVER["REQUEST_URI"], append it to the new domain and issue the header() statements.  You might also log the redirects to a data base if you wanted to see them occurring.  Just a thought, ~Ray
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36919286
Hi @Ray Pauser, how I do that in php if all the files are .htm. I thing I cant write php in a .htm file, or don't?

Hi @mankowitz, can ypu give me a example for one file .htaccess and with 3 URL's?
This question is because I don't know how the system know the URL belongs.
???????RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]??????????????

Regards, JC
0
 
LVL 24

Accepted Solution

by:
mankowitz earned 1400 total points
ID: 36920855
create a new file called .htaccess in the root directory of www.example.com, at the same level where the index.htm file is.

In that file, put the following text:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36920936
The problem is the structure of the site. The main site stay in root and have a file index.htm too, the other index.htm stay all inside folders, folder1, folder2, etc.
You can see the structure here http://rdsrc.us/7L1N99
If you visit the link above you will see the main page. If you click in one of the links in the middle right or left, will open the other index.htm files, and that ones are in folders.

After you see my real problem what you suggest?

The best regards, JC
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 600 total points
ID: 36923683
I think I cant write php in a .htm file, or don't?

You can parse .htm files through the PHP parser.  Use AddHandler to connect the file types and the parser.  But if the .htm files do not use PHP this might not be necessary.

You can put .htaccess files in the root directory and in the other directories, too.  
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 36923797
ok, one more time: you should only have to create the .htaccess folder in the top level folder where you want it to work. it should automatically cascade down to all subfolders.

SOOOO

suppose you have these directories

www/
www/geres
www/geres/primo
www/geres/mano
www/portugal
www/portugal/tourism


and you want to forward them all. If you put the .htaccess file in the "www/" directory it will work as though it was in all the other directories as well, because they are all children of that initial directory. Get it?
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36923804
Hi, The html files not use PHP, when I create that project understanding Php was a dream. That project is pure html only.
But I'm curious about the Php Parser. I thing the best idea is create a header (with the 301 redirect) for each page, but my knolgment I thing I can't use Php in .html pages. Now you talking about the Php Parser, and sounds that is possible (use Php in html files).
Can you explain better the Php Parser? If was until for my case!
Or Should I open a new question?
Regards, JC
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36923887
Hi @mankowitz, I get it!
By other words, and if I understand, that redirect you suggest working like a mirror?!
If I use that redirect, the same folders have to be create in the new server, correct?
Regards, JC
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 36932243
right.
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 36958023
Hi E's, I'm note close this question yet, because I'm waiting a answer from my hosting support.
Soon I be back to assign the points and close the question.

The best regards, JC
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 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