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]
try adding the following to your .htaccess file in the root of your domain
This line
is going to send some pages to phppage.php even though they don't look like
because there is no mention of phppage in the first argument to RewriteRule.