1

I'm coding in PHP, and have implemented a htaccess code which removes the file extension (in this case '.php').

The problem is, this doesn't allow directories to remove the index.php on the end.

I.E. http://www.domain.com/about/ - The requested URL /about/.php was not found on this server.

Here is my current code:

Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/ RewriteRule ^(([^/]+/)*[^.]+)\.php http://www.domain.com/$1 [R=301,L] Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^index\.php/?$ / [L,R=301,NC] 

I want to have /about/ redirect to /about/index.php, while just showing /about/

Thanks in advance guys!

1 Answer 1

1

just use DirectorySlash in htaccess file apatche automatically appends trailing slash after directory names

DirectorySlash On 

if you want call the directory without the trailing slash try:

DirectorySlash Off 
Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately that hasn't fixed it. It's throwing the same error.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.