BrainPill Posted February 24, 2020 Share Posted February 24, 2020 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 More sharing options...
dsonesuk Posted February 24, 2020 Share Posted February 24, 2020 Look up mod_rewrite. Make sure its enabled first. Link to comment Share on other sites More sharing options...
BrainPill Posted February 25, 2020 Author Share Posted February 25, 2020 (edited) it is enabled. I can see it in php_info() in the list under apache2handler : loaded modules Other directives do work in the .htaccess file, but this one doesn't. Are there additional requirements? Edited February 25, 2020 by BrainPill Link to comment Share on other sites More sharing options...
BrainPill Posted February 25, 2020 Author Share Posted February 25, 2020 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 More sharing options...
dsonesuk Posted February 25, 2020 Share Posted February 25, 2020 https://stackoverflow.com/questions/35508635/allowoverride-not-allowed-here Link to comment Share on other sites More sharing options...
BrainPill Posted February 26, 2020 Author Share Posted February 26, 2020 13 hours ago, dsonesuk said: https://stackoverflow.com/questions/35508635/allowoverride-not-allowed-here 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 More sharing options...
BrainPill Posted February 26, 2020 Author Share Posted February 26, 2020 I solved it meanwhile Link to comment Share on other sites More sharing options...
dsonesuk Posted February 26, 2020 Share Posted February 26, 2020 (edited) You need to restart all services. Edited February 26, 2020 by dsonesuk Link to comment Share on other sites More sharing options...
hostguy Posted March 30, 2021 Share Posted March 30, 2021 (edited) 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 March 30, 2021 by Ingolme Removed advertising link Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now