How to Add URL Suffix
-
19-09-2019 - |
Question
I just want to ask that how do i add html suffix to each url of my site using htaccess?
A url like this:
www.mysite.com/index.php?hello/world
should become
www.mysite.com/index.php?hello/world.html
Solution
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1\.html [R=301,L]
OTHER TIPS
Another approach is to turn on MultiViews. Simply add the following line to a .htaccess
file in the directory (or httpd.conf). Note that Options All
does NOT turn on MultiViews, you need to explicitly turn it on.
Options +MultiViews
See the MultiViews section in http://httpd.apache.org/docs/2.0/en/content-negotiation.html for more info on what it does and http://httpd.apache.org/docs/2.0/en/mod/core.html#options for more info on options.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow