【发布时间】:2015-03-26 05:38:20
【问题描述】:
我在 .htaccess 中隐藏 URL 时遇到问题。我想从 URL 中删除 .php。
例如:将www.example.com/destination_info.php/Laos-destination-trip 转换为www.example.com/destination_info/Laos-destination-trip
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^./]+)/(.+)$ $1.php/$2 [L]
【问题讨论】:
-
请描述您遇到的问题。
-
如果 url 是:: www.example.com/test.php,它应该显示 www.example.com/test .. 吗?
标签: regex apache .htaccess mod-rewrite url-rewriting