附加*到无扩展URL路径
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了附加*到无扩展URL路径相关的知识,希望对你有一定的参考价值。
I, personally, avoid using extensions like .php in my URLs. For example: http://www.example.com/contact http://www.example.com/contact.php Not only does the first URL look cleaner, but if I decided to switch languages, it would be less of an issue. So how does one implement this? Here is the .htaccess code I found works best: # If requested URL-path plus ".php" exists as a file RewriteCond %{DOCUMENT_ROOT}/$1.php -f # Rewrite to append ".php" to extensionless URL-path RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L] Source: http://www.webmasterworld.com/apache/3609508.htm answered Oct 21 '10 at 5:11 community wiki Adam
以上是关于附加*到无扩展URL路径的主要内容,如果未能解决你的问题,请参考以下文章
.htaccess 中的 301 重定向将旧文件路径/名称附加到新 url
使用 PHP 从 URL 字符串中获取文件路径/扩展名 [重复]
写一个函数,尽可能高效的,从一个标准 url 里取出文件的扩展名?pathinfo文件路径& parse_url解析url & basename路径中文件名