开发者

Remove .php from URL and force a trailing slash /

开发者 https://www.devze.com 2023-04-08 12:35 出处:网络
I want to us开发者_如何学Ce .htaccess mod_rewrite to remove .php from all my files and force a trailing slash /. However, it is only resulting in me getting server errors.You want to map :

I want to us开发者_如何学Ce .htaccess mod_rewrite to remove .php from all my files and force a trailing slash /. However, it is only resulting in me getting server errors.


You want to map :

http://sampledomain.ext/index/ -> http://sampledomain.ext/index.html

Use the following .htaccess

 RewriteEngine On
 RewriteCond %{REQUEST_URI} ! \.php$ #Avoid real php page, do what you want with them
 RewriteCond %{REQUEST_URI} /$       #Ensure a final slash
 RewriteRule ^(.*)$ $1.php           #Add your extension

Tx to David Wolever who write quitely the same stuff 1

If I can give my opinion, it's a little bit strange to force the / at the end for a file no?

0

精彩评论

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