Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite php to htm

         

helenp

9:12 am on Nov 15, 2005 (gmt 0)

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



Hi,
I donīt understand anything of mod rewrite.
I have an site with about 300 pages,
about 270 are .htm and 30 are .php
I want to migrate several pages to .php and bit by bit
properbly all will end being .php.

Could I have an rule that makes all .php seems like they are .htm?
I suppose yes,
but could I have that rule having .htm pages and .php pages as well?
All links goes to myhomepages.htm

This code I have in .htaccess to prevent spiders index non www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule (.*) [mysite.com...] [R=301,L]

I have one homepage,
and four other index.htm pages in directories.

jd01

10:24 am on Nov 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure I understand the question...

Are you wanting to serve the information from the php file to equivalent htm files? (Recommended if you will be changing a portion of files to dynamic)

OR

301 (Redirect) the htm files to the php files? (Not recommended)

OR

Have your current htm files parsed as php, so you do not have to change extentions? (Recommended if you will be changing all files to dynamic)

The answer for all 3 is different, and I am not sure what you are looking for. There is some basic information about mod_rewrite in the Apache Library [webmasterworld.com] that might help you understand what mod_rewrite is and does.

Please, let us know.

Justin

helenp

10:38 am on Nov 15, 2005 (gmt 0)

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



Actually,
The site was initially all files in .htm
I added an database so about 30 pages are at this moment .php

The rest of pages including the index files are still .htm

I want to do some changes, as inserting searchers etc, so bit by bit some pages will change extension from .htm to .php at this moment I will change 200 pages to .php and maybe later on as well the index pages will change to .php.

Though the searchengines have indexed about 250 .htm files and 30 .php files,
Wouldnīt the best be to forget about the 30 .php files and tell the searchengines to index all .php files to .htm so that I can keep on changing all files to .htm?
I am a bit lost, and very frightened about changing the extension, though we are very well positioned in search engines.

helenp

3:40 pm on Nov 15, 2005 (gmt 0)

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



I suppose this is what I should do:
AddType application/x-httpd-php htm

Is that the best choise?
This wonīt give me any problems with searchengines?
Will this give an delay in browsing though the server needs to parse the pages.
Doing that the pages that already is called .php should I rename them to .htm or can they stay that way?

jd01

8:20 pm on Nov 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Helen,

The AddHandler should be fine, as long as you have mod_mime installed -- You will know if you try it. It will either work or you will get a 500 server error

With the size of your site, the Handler should not be a problem for either server load or load time.

I have heard some horror stories about changing extentions, so I think it is much better to avoid it -- at least one SE (Google) views new extentions as new pages, and may determine your entire site is new if you change them...

You should not need to change any page names -- the php should be fine the way they are, and the .htm will be run through the php engine the same as php pages.

Hope this helps.

Let us know if you get stuck.

Justin

helenp

8:58 pm on Nov 15, 2005 (gmt 0)

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



thanks a lot

Dijkgraaf

4:14 am on Nov 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only downside of adding that handler is that the response changes a bit for all htm files, see the examples below.
This will results in that pages being server up new each time they are requested and will never give a 304 response again.
So if you want these pages to have cache handeling, you will have to add it to those htm files
Have a look at
[alexandre.alapetite.net...] for a good example.

-- not processed as PHP
HTTP/1.1 200 OK
Date: Wed, 09 Nov 2005 22:41:51 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) FrontPage/5.0.2.2623 mod_ssl/2.8.22
OpenSSL/0.9.7e
Last-Modified: Sun, 26 Jun 2005 23:14:32 GMT
ETag: "85c94-379b-42bf36d8"
Accept-Ranges: bytes
Content-Length: 14235
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

-- processed as PHP
HTTP/1.1 200 OK
Date: Wed, 09 Nov 2005 22:41:03 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) FrontPage/5.0.2.2623 mod_ssl/2.8.22
OpenSSL/0.9.7e
Connection: close
Content-Type: text/html

helenp

8:55 am on Nov 16, 2005 (gmt 0)

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



Sounds complicated and an very long code.....
So I would need to add that module and put it in an require_once at the top of all pages.

Any inconvenience of doing that?

helenp

7:17 pm on Nov 16, 2005 (gmt 0)

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



I was thinking trying to read about it but canīt find it, to technical and my english...arenīt to perfect.

The first option:

Are you wanting to serve the information from the php file to equivalent htm files? (Recommended if you will be changing a portion of files to dynamic)

Actually I really donīt know what it is and why should I only use it if a portion of files will be changed.
Maybe is better than option 3.
Definitevily I will not do an redirect (option 2)