Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Redirect *.htm to *.php

    I'm wanting to automatically redirect all requests for *.htm or *.html to a *.php file by the same name.

    How could I do this with htaccess? I've googled and searched on this forum to no avail...

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    By using Apache's mod_rewrite. See <http://www.modrewrite.com/>.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I figured that much. I've spent the last hour trying to get all *.htm and *.html requests to redirect to *.php files by the same name (in all directories), but it plain isn't working.

    I'll keep working at it, but meanwhile has anyone got a specific script that I can just drop into my .htaccess file?

  • #4
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    403
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    RedirectMatch permanent (.*)\.html$ $1.php
    or

    Code:
    RewriteEngine on
    RewriteRule ^(.*)\.htm[l]?(.*) /$1.php$2
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You can use .htaccess to make the server parse .htm and/or .html files. The there would not be an issue, keep the extensions as they were originally.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •