.html pages redirect to .php pages

Discussion in 'Site & Server Administration' started by waelthmastery, Aug 2, 2006.

  1. #1
    Hi tried to redirect my .html pages to .php pages... and added the following commands. Does not seem to work... Any help?

    Options +FollowSymlinks
    RewriteEngine On
    RewriteRule ^(.+)\.htm$ http://www.realhitch.com/$1.php [r=301,nc]
     
    waelthmastery, Aug 2, 2006 IP
  2. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Where did you add these commands ?

    Also, you wrote "Does not seem to work" : can you be more specific ?

    Jean-Luc
     
    Jean-Luc, Aug 2, 2006 IP
  3. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Edit the .htaccess file as follows:

    
    RewriteEngine on
    
    RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
    
    # rewrite to document.php if exists
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [S=1]
    
    # else reverse the previous basename cutout
    RewriteCond %{ENV:WasHTML} ^yes$
    RewriteRule ^(.*)$ $1.html
    
    Code (markup):
    Your apache configuration must enable the rewrite engine and allow you to invoke it.
     
    clancey, Aug 2, 2006 IP
    ahkip likes this.
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Don't redirect them just make your server process php as html.
     
    mad4, Aug 3, 2006 IP
  5. waelthmastery

    waelthmastery Peon

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi guys, thanks! Whihcever I do it does not work, meaning it does not go to the .php pages. Could it be with the host?
     
    waelthmastery, Aug 3, 2006 IP
  6. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If the .htaccess changes suggested above do not work, then your host is not allowing you to do so. You cannot use the RewriteEngine unless mod_rewrite has been enabled and your site has been given the requisite permissions by your host.
     
    clancey, Aug 3, 2006 IP