【发布时间】:2015-04-09 20:41:24
【问题描述】:
我想用.htaccess 重写php 扩展。我想用斜杠 / 替换 php 扩展名。例如,如果我有:http://example.com/about-us.php 将是 http://example.com/about-us/
如何修改这段代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteRule .*[^/]$ $0/ [L,R=301]
谢谢大家!!!
【问题讨论】:
-
你看到我的更新了吗??
标签: regex apache .htaccess mod-rewrite