1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I do simple flat link to .php file redirect?

Discussion in 'Apache' started by mrtdmb, Jan 11, 2015.

  1. #1
    My current .htaccess file is as

    Options +FollowSymlinks
    RewriteEngine On

    RewriteRule ^(.+)\.html$ $1.php [L]​

    This is at the directory level, I do not want to have a site-wide .htaccess.

    I can redirect ../file.html to ../file.php but I am not able to do it for ../file/ -> ../file.php

    What exactly I need to change on this code to be able to do that?

    I have found many tutorials but they almost always assume I am doing .htaccess at the root level, whereas I would like to do this for a single directory.

    Thanks in advance
     
    mrtdmb, Jan 11, 2015 IP
  2. mrtdmb

    mrtdmb Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Found a solution:

    Options +FollowSymlinks
    RewriteEngine On

    RewriteRule ^([a-zA-Z0-9_-]+)/?$ $1.php [L]
     
    mrtdmb, Jan 11, 2015 IP