force pages to end in a slash and rewrite the url
i have to call my pages in this way:
http://example.com/index.php?page=homepage
i want to always show the url in this way
http://example.com/homepage
and at the same time i also want to prevent the insertion of the / at the end of the url...so:
http://example.com/homepage/ or http://example.com/homepage
point to the same page. how can i do this trick 开发者_如何学Pythonwith htacces? have i to correct all relative path of files in my html?
thanks a lot
# activate Rewrite Engine
RewriteEngine On
# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
# remove trailing slash
RewriteRule ^(.+)/$ $1 [R=301,L,QSA]
# rewrite all other requests to index.php
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
RewriteEngine on
RewriteBase /
RewriteRule ^(css|js)/(.*)?$ $1/$2 [L]
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
RewriteRule ^(.*)/$ $1 [R]
Last update from this.
精彩评论