Reputation: 1279
I have a website say www.domain.com
It has a html page say at www.domain.com/page.html
It does not load when I add a / at the end as in
www.domain.com/page.html/
I think its because its trying to assume / as a folder and tries to see if there is anything inside the page.html folder.
So, how do I fix this? What needs to done to make all my .html files work fine even if:
Any solution with best practices please?
The reason is to direct all the traffic to the correct relevant pages of my site.
Upvotes: 1
Views: 371
Reputation: 785581
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} /$
RewriteRule ^(.+?)\.html?/?$ /$1.html [L,NC,R=302]
Upvotes: 1
Reputation: 331
Are you trying this with localhost and you're not able to see localhost/domainexample/page.html/ because of trailing slash? if yes then you better look for virtual host so your domain will look like live domain
Upvotes: 1