Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想通过 htaccess 文件从 url 中删除 .php 扩展名。请让我知道我该怎么做?
url:http://domain name/profile.php
我想要这样
url:http://domain name/profile
您需要阅读它以便能够编写正则表达式并以不同的方式使用 .htaccess,但简单的重写将如下所示:
RewriteEngine on RewriteRule ^profile$ profile.php [L]
如果你想全局删除所有 .php 扩展名但保留文件名,你需要一个看起来像这样的正则表达式:
RewriteRule ^([a-zA-Z0-9\-_]+).php$ $1.php [L]