#StackBounty: #php #.htaccess htaccess – multiple extension hiding

Bounty: 50

I want to remove .html and .php extensions in my .htaccess file. I want the users to be able to view www.example.com/page.php by clicking either www.example.com/page.php or www.example.com/page, but the browser always to show www.example.com/page

Tried a few options I found online, and this one was working for me:

RewriteCond %{THE_REQUEST} /([^.]+).html [NC] 
RewriteRule ^ /%1 [NC,L,R] 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^ %{REQUEST_URI}.html [NC,L] 
RewriteCond %{THE_REQUEST} /([^.]+).php [NC] 
RewriteRule ^ /%1 [NC,L,R] 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

Which I thought was great, I could browse between pages like I mentioned above.

However, it then failed trying to log in to any of my pages. When I entered the credentials, it would just re-open the page I was on, with no error message.

The .php pages have a require("connection.php"); in the file to get the access to the database.

Then goes something like:

        // check credentials
        // redirect to specific page
<!DOCTYPE html>
    <form action="index.php" method="post">
    // the rest of the form

If I comment out the php rewrites in the .htaccess the login works as expected. It’s not a database issue, as I can view pages that display data from there with no issues.

Is there something in my .htaccess file that’s improperly redirecting my .php pages?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.