【发布时间】:2014-03-15 16:48:19
【问题描述】:
如果我有一个看起来像这样的网址:
localhost/category.php?id=name&phrase=something
我可以使用什么 .htaccess 重写规则代码使其看起来像:
localhost/name/something
以下是我的 .htaccess 文件目前的样子:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?article/([^/]*)$ /article.php?id=$1 [L]
RewriteRule ^/?wrestler/([^/]*)$ /wrestler.php?id=$1 [L]
# Removes the .php extension from pages
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
大家有什么想法吗?
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite