【发布时间】:2014-12-03 18:55:39
【问题描述】:
我有更多页面(在同一位置)具有以下名称:
site.com/common_page1.php
site.com/common_page2.php
site.com/common_page3.php
...
等等。
我想将具有该模式的每个页面重定向到:
site.com/page1
site.com/page2
site.com/page3
所以我必须隐藏“.php”扩展名和“common_”
我已经完成了第一部分:
RewriteEngine On
## hide .php extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC]
RewriteRule ^ %1 [R=301,L]
## To internally forward
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
但我坚持“common_”规则。
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect url-rewriting