I'm using htaccess for the first time to make pretty urls for my website html files and 1 php file. I was just wondering if I would be able to get some advice on my htaccess file set up and if how I have it set up is a good way? I'd hate for my urls to not work in some situation because of what I have written. :(
Example html file:
before: http://www.domain.com/subdomain/htmlpage.html
after: http://www.domain.com/subdomain/htmlpage/
Single php file:
before: http://www.domain.com/subdomain/phppage.php?p=1
after: http://www.domain.com/subdomain/phppage/1/
I have added in a rule to redirect index.html to index.php. I've also had to add 'base href' in the head of each file because I've used relative links.
the htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index.html?$ / [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]
RewriteRule ^(.+)/([0-9]+)/?$ phppage.php?p=$1 [L]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…