0

I have these urls in my blog

http://myblog.com/news/post1/index.php
http://myblog.com/updates/post3/index.html
http://myblog.com/index.html
http://myblog.com/blog/post4/index.php

How do I setup .htaccess so that all the urls will end with "/"

http://myblog.com/news/post1/
http://myblog.com/updates/post3/
http://myblog.com/
http://myblog.com/blog/post4/

Thanks in advance!

0

1 Answer 1

1

To remove the .php extension from a PHP file:

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

If you want to remove the .html extension from a html file:

RewriteRule ^([^\.]+)$ $1.html [NC,L] 

Or see this post:

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

1 Comment

This translates /example/file.php to /example/file. The question was how to redirect /example/index.php or /example/index.html to /example/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.