.htaccess remove .html file/directory priority rewrite
I'm trying to rewrite so you can access files without .html and without
adding a trailing slash. here's the code being used:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*?)/?$
RewriteCond %{DOCUMENT_ROOT}/%1.html -f
RewriteRule ^(.*?)/?$ $1.html
But for my file structure on the server where I have this:
/public_html
..
/beginners
beginners.html
and inside /beginners folder there's other files, e.g.
/beginners/page1.html
I need rewrites to work like this:
if user inputs url: website.com/beginners - the server would return the
contents of file beginners.html currently it returns the contents of the
directory /beginners . so i need the server to first check if
beginners.html exists, if yes - then server serves beginners.html not the
directory /beginners
if the user accesses url website.com/beginners/page1 the server should
first check up if page1.html exists in the folder beginners and if it
finds the file page1.html then it serves the contents of the file
page1.html
can this be done?
No comments:
Post a Comment