删除web URL中的扩展名和尾部斜杠:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了删除web URL中的扩展名和尾部斜杠:相关的知识,希望对你有一定的参考价值。

Removing extensions and trailing slashes in web urls:
"If you want to remove the .html extension from a html file for example yoursite.com/wallpaper.html to yoursite.com/wallpaper you simply have to alter the last line from the code above to match the filename"
Not sure if the middle 2 lines are needed.
  1. RewriteEngine On
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteRule ^([^/]+)/$ $1.php
  4. RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
  5.  
  6. RewriteRule ^([^.]+)$ $1.html [NC,L]
  7. RewriteRule ^([^.]+)$ $1.htm [NC,L]
  8.  
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
  12. RewriteRule (.*)$ /$1/ [R=301,L]

以上是关于删除web URL中的扩展名和尾部斜杠:的主要内容,如果未能解决你的问题,请参考以下文章