Forum Moderators: phranque

Message Too Old, No Replies

quick check that this is the proper rewrite

site changing from htm to php

         

knotworking

1:23 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



Can anyone tell me if this is what I want to be doing? My content is basically all the same on my old 'htm' pages and my new 'php' pages, it just makes updates and life easier to convert everything to php. I have a line for every converted page in my htaccess like this:

RewriteRule ^index\.htm$ index.php [R=301,L]
RewriteRule ^aboutus\.htm$ aboutus.php [R=301,L]

It's working fine but, I am concerned about the SEs. Don't want to get penalized for dupe content or anything. Is the above correct?

Thanks!

knotworking

1:46 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



Well, I used the header checker here and, it is returning a 301 properly but, when I go to the old page in my browser, it doesn't redirect to the new page. If I remove the R=301 and just have [L], the redirect works and the header returns 200.

Am I doing something wrong?

jamie

2:05 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



knotworking.

why don't you just set the server to parse your .htm pages as .php pages. that way you needn't bother redirecting.

you need to add
AddHandler application/x-httpd-php .htm .html

to your htaccess file

knotworking

2:24 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



I still have several htm pages (privacypolicy, etc) that I won't convert. Wouldn't that affect their parsing, as well?

I got the problem fixed. I was not specifying the full URL, it should be:

RewriteRule ^index\.htm$ [mysite.com...] [R=301,L]

Not
RewriteRule ^index\.htm$ index.php [R=301,L]

jdMorgan

2:29 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The preferred format is:

RewriteRule ^index\.htm$ http://www.example.com/index.php [R=301,L]
RewriteRule ^aboutus\.htm$ http://www.example.com/aboutus.php [R=301,L]

If *all* html pages are to be redirected to php pages, then you can do them all with one Rule:

RewriteRule ^([^.]+)\.htm$ http://www.example.com/$1.php [R=301,L]

Duplicate content is not a problem, because you are telling the client that the resource has moved to a new URL.

Important: Flush your browser cache after *any* change to your .htaccess code.

As jamie says, it's often easier to just leave the URLs alone and have the server parse .html files as .php. Since the output from a PHP page is HTML, this is an entirely acceptable thing to do, and your URLs don't have to change.

Jim

knotworking

2:38 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



Yeah, I'm keeping a few html pages around for kicks so, I'm doing the page rewrites. Seems to be working.

Now, to see what happens to my referrals.