301 redirect

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
LVL 3
Pedro ChagasWebmasterAsked:
Who is Participating?
 
mankowitzCommented:
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
 
mankowitzCommented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mankowitzCommented:
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
 
Ray PaseurCommented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
 
Ray PaseurCommented:
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
 
mankowitzCommented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
 
Pedro ChagasWebmasterAuthor Commented:
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
 
mankowitzCommented:
right.
0
 
Pedro ChagasWebmasterAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.