Riparian Posted May 24, 2010 Share Posted May 24, 2010 I have seen this code many times and tried to instigate it many times but it simply does nothing on my server. It is a unix server running apache The code must be ok as I do not get errors. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php does anyone have any ideas ? I also have another instance of - RewriteEngine on - is it acceptable to have 2 seperate ones or should they be combined ? Cheers and thanks Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/ Share on other sites More sharing options...
cags Posted May 24, 2010 Share Posted May 24, 2010 You don't need two instances of RewriteEngine on in the same file, so scrap one. You say it doesn't work, how are you testing it? What URL are you entering? Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1062550 Share on other sites More sharing options...
Riparian Posted May 26, 2010 Author Share Posted May 26, 2010 Thanks for the reply this is the re-write part of the htaccess : # re-write http://ausspecs.com.au to http://.www.ausspecs.com.au RewriteEngine on RewriteCond %{HTTP_HOST} ausspecs\.com.au [NC] RewriteCond %{HTTP_HOST} !^www\.ausspecs\.com.au [NC] RewriteRule ^(.*) http://www.ausspecs\.com.au/$1 [R=301] # HIDE THE PHP EXTENSION RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php an example of what I am typing is http://www.ausspecs.com.au/great_specs.php but even clicking on any of the links from the index page does not achieve the result. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1063853 Share on other sites More sharing options...
cags Posted May 26, 2010 Share Posted May 26, 2010 You appear to be under the common (bane of my existence) misconception about how mod_rewrite works and what it does. You're comment is misleading because it says 'hide the PHP extension', this is not what the code does infact it's the opposite. The code ADDs the php extension to requests that don't have it. The point of the code is to take a request for http://www.ausspecs.au/great_specs and rewrite it to http://www.ausspecs.au/great_specs.php. Thus to test that rule you have to request http://www.ausspecs.au/great_specs. Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1063860 Share on other sites More sharing options...
Riparian Posted May 27, 2010 Author Share Posted May 27, 2010 Thank you Cags... I apologize for wasting your time. From all of the instances I have seen the code mentioned this is by no means what I expected. I certainly appreciate you taking the time to enlighten me . Cheers Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1064393 Share on other sites More sharing options...
cags Posted May 27, 2010 Share Posted May 27, 2010 No worries, it seems everyone that first comes here is attempting it back to front. Quote Link to comment https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1064394 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.