-2

I am trying to replace everything ending with the extension html (.html) with a trailing (\) slash i.e.

http://www.example.com/ibizaparty.html to http://www.example.com/ibizaparty/

How can this be resolved using .htaccess i.e. redirect/rewrite rules?

Your help is greatly appreciated?

TSA
  • 1
  • Can you please show us any attempt? Currently, you have nothing to show us. And this is quite a trivial thing to do. – Ismael Miguel Aug 23 '15 at 11:49
  • There are about 56393658937 examples for this here on SO. None of that helped? Please note that this is not a code writing service. You are expected to write your own code. Only if you run into a _specific_ issue, then is the time to ask here. Do not get this wrong. We are not trying to be rude here. We just try to keep the quality of questions high. – arkascha Aug 23 '15 at 11:56
  • http://stackoverflow.com/q/1068595/2729937 http://stackoverflow.com/q/29548556/2729937 http://stackoverflow.com/q/18732100/2729937 <-- pick one, try it. – Ismael Miguel Aug 23 '15 at 11:59

1 Answers1

0

I'm giving you the code but for future questions please look around and search the site before you just make a question that has been answered millions of times.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html 

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
Shivam Paw
  • 203
  • 3
  • 14