开发者

force pages to end in a slash and rewrite the url

开发者 https://www.devze.com 2023-03-15 07:52 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消