BrainPill 1 Posted February 24, 2020 Report 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? Quote Link to post Share on other sites
dsonesuk 929 Posted February 24, 2020 Report Share Posted February 24, 2020 Look up mod_rewrite. Make sure its enabled first. Quote Link to post Share on other sites
BrainPill 1 Posted February 25, 2020 Author Report 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 Quote Link to post Share on other sites
BrainPill 1 Posted February 25, 2020 Author Report 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? Quote Link to post Share on other sites
dsonesuk 929 Posted February 25, 2020 Report Share Posted February 25, 2020 https://stackoverflow.com/questions/35508635/allowoverride-not-allowed-here Quote Link to post Share on other sites
BrainPill 1 Posted February 26, 2020 Author Report 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? Quote Link to post Share on other sites
BrainPill 1 Posted February 26, 2020 Author Report Share Posted February 26, 2020 I solved it meanwhile Quote Link to post Share on other sites
dsonesuk 929 Posted February 26, 2020 Report Share Posted February 26, 2020 (edited) You need to restart all services. Edited February 26, 2020 by dsonesuk Quote Link to post Share on other sites
hostguy 0 Posted March 30 Report Share Posted March 30 (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 by Ingolme Removed advertising link Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.