jackmaessen Posted January 8, 2013 Share Posted January 8, 2013 Hello, I am trying to remove my .php extensions with rewrite_mod. I use this code in my .htaccess file which is in the webroot: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php In my apache httpd.conf file, i removed the # sign from the LoadModule But it is still not working for me Can anyone tell me why it does not work? Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/ Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 Have you restarted Apache? Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404232 Share on other sites More sharing options...
jackmaessen Posted January 8, 2013 Author Share Posted January 8, 2013 yes i did restart all services Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404239 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 Well you need to escape the dot in your second condition. Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404262 Share on other sites More sharing options...
jackmaessen Posted January 8, 2013 Author Share Posted January 8, 2013 i do not understand what you mean by escape Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404271 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 (edited) You have special characters in most if not all computer languages that represent something. In this case a dot/period/. - in the second condition - matches the requested file name, followed by some character, followed by "php". E.g. "myfilexphp", "myfile4php", "myfile:php" are all valid but technically incorrect. To ensure it matches a dot only you must escape the special character; this applies to every special character. This can be done by using a backslash although it may be another character in some languages (I'm yet to see one where its not a backslash). So your condition should read: RewriteCond %{REQUEST_FILENAME}\.php -f Edited January 8, 2013 by cpd Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404275 Share on other sites More sharing options...
jackmaessen Posted January 8, 2013 Author Share Posted January 8, 2013 (edited) that also doesnt work my code: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php I tried also a space between } and \, but gives me a 500 server error RewriteCond %{REQUEST_FILENAME} \.php -f i have tried so many things, but nothing seems to work Edited January 8, 2013 by jackmaessen Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404276 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 Are you running this on WAMP or something? It sounds like mod_rewrite isn't enabled. Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404287 Share on other sites More sharing options...
jackmaessen Posted January 8, 2013 Author Share Posted January 8, 2013 (edited) yes i am running it on WAMP, but in the httpd.config file, i removed the # sign from the line: LoadModule rewrite_module modules/mod_rewrite.so So modification rewrite must be enabled Edited January 8, 2013 by jackmaessen Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404292 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 (edited) Click WAMP -> Apache -> Apache Modules and see if mod_rewrite is enabled. Edit: it should be called rewrite_module. Edited January 8, 2013 by cpd Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404293 Share on other sites More sharing options...
jackmaessen Posted January 8, 2013 Author Share Posted January 8, 2013 yes it is enabled; there is a V sign for the line Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404316 Share on other sites More sharing options...
cpd Posted January 8, 2013 Share Posted January 8, 2013 Have you tried closing and restarting WAMP altogether to be absolutely sure? Quote Link to comment https://forums.phpfreaks.com/topic/272849-modification-rewrite-doesnt-work/#findComment-1404341 Share on other sites More sharing options...
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.