Jump to content

how to remove *.php extension in address url ?


BrainPill

Recommended Posts

I have a question about apache.

I have WAMP version 3.1.9

apache 2.4.39

I want to remove the *.php extension in the url

in the .htaccess file which I placed in the directory ; I added the following code

 
 RemoveType *.php

but still when going to a page I see the php extension

in the apache pages I read that the loaded module should be mod_mime 

https://httpd.apache.org/docs/2.4/mod/mod_mime.html#removetype

(i can see its loaded when checking php_info() ) 

still I dont have any result. 

What more directives are needed?

Or is there another approach for removing file extensions?

 

Link to comment
Share on other sites

I tried to put this in the htaccess file

AllowOverride All
 
RewriteEngine On
RewriteRule ^([^\.]+)$ $1.php [NC,L]

But this makes the request crash

the apache error logs tells: 

Quote

[Tue Feb 25 13:52:53.697348 2020] [core:alert] [pid 10960:tid 1236] [client ::1:50614] C:/wamp64/www/mydirectory/.htaccess: AllowOverride not allowed here, referer: http://www.myvirthost.loc

Why is this error showing up?

Link to comment
Share on other sites

13 hours ago, dsonesuk said:

I have this direction placed in the vhosts file

 

 Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
 	   Require all granted

Could it be any other script that still overrides this ? I tried the same ones in the httpd.conf file but I am not sure how to do it. 

Is the httpd directive more determining for instance ?

What else could it be? 

 

Link to comment
Share on other sites

  • 1 year later...

I know this issue is resolved but below code works for me so you can check this.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php –f
RewriteRule ^(.*)$ $1.php [NC,L]

You have to add this code in .htaccess file to remove .php extension.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html –f
RewriteRule ^(.*)$ $1.html [NC,L]

You can use this code to remove .htaccess file extension.

 

Edited by Ingolme
Removed advertising link
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...