/page/ grabs content page.php

Discussion in 'Apache' started by mark_s, Apr 15, 2008.

  1. #1
    I have a question and hope someone can help me...

    I want it so that if someone types in /page/ the server automatically loads the content of page.php but only shows it as /page/. So whatever typed in, the server will automatically assume the content is in the equivalent filename with .php at the end. Is this possible with mod_rewrite?
     
    mark_s, Apr 15, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Yes.

    You'd do something like

    
    RewriteEngine On
    RewriteRule ^([^/]+)/$ $1.php
    
    Code (markup):
    Untested, but should form a guide.

    Jay
     
    jayshah, Apr 15, 2008 IP
  3. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That didn't work unfortunately :(
     
    mark_s, Apr 15, 2008 IP
  4. Ni9htRider

    Ni9htRider Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    RewriteEngine On
    RewriteRule ^(.*)/$ $1.php
    
    Code (markup):
     
    Ni9htRider, Apr 17, 2008 IP