Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/202706-help-with-htaccess/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1063853
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/202706-help-with-htaccess/#findComment-1063860
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.