How to remove .html, .php from links


I tried a tutorial on how to hide the .html and .php in .htaccess but I am unsure if it works with infinity free…? It does not seem to work.




RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $1.php

1 Like


Make a folder called login
Move login.php into login and rename it index.php

Nah, the thing actually worked, just had to re do the redirects by removing the .php in them, but thanks anyways.

Ah, good luck!

It’s the most unprofessional way to do it.

But it works.

Yes it works but:

  1. It will make problems for including php files from other directories (can be using…/)
  2. It’ll increase used inodes to 2x.

And why creating lots of folders and index.php files for that purpose while a small htaccess code snippet will do the job? :slight_smile:

Never though of it that way. But you could use DIR with PHP, but yeah I guess, like i say im just suggesting an alternate way.

I use this method, it has never failed me in the past:

# Allows url to be loaded without .html/.php
Options +MultiViews

# Redirects from .php to no .php
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC] 

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.