Easy way?

  • Thread starter Samuël van Laere
  • Start date
S

Samuël van Laere

Is there a easy way to catch a request for myfile.htm and forward it to
myfile.php?

..htm files are no longer available, i'm going to change there names to .php
i just wonder if there is a way to do it so visitors don't get a 404
when trying to request the old file name.
 
S

Samuël van Laere

David Dorward said:
Depends on the server.


Its not my server, but i believe it runs apache.
I have access to the htacces file, but have not found anything that could
help me. I can run php and are able to use a mysql database.
Perhaps i should use php for this?
 
B

brucie

Is there a easy way to catch a request for myfile.htm and forward it to
myfile.php?

(assumes apache) stick one of the below in a .htaccess file[1] for the
directory you want the directives to apply to. child directories
inherit the directives so if you stick it in your root the directives
will apply to all of your site.

only redirect myfile.htm to myfile.php:

RedirectMatch permanent (myfile.*)\.htm$ $1.php

redirect all files from .htm to .php:

RedirectMatch permanent ^(.*)\.htm$ $1.php

or the below to parse htm files as if they were php to save renaming

AddType application/x-httpd-php .htm

[1] a .htaccess file is a plain text file named as shown. if you
create the file with notepad save the file with quotes to prevent
notepad from adding a .txt extension i.e: ".htaccess"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,811
Messages
2,569,693
Members
45,478
Latest member
dontilydondon

Latest Threads

Top