【发布时间】:2016-12-10 06:34:58
【问题描述】:
我的网站根目录中有一个文件user.php。要访问用户的页面,您可以访问/user/foo-bar,其中foo-bar 是用户名。
我的目标是:
-
mysite.com/user重定向回index.php的根目录 -
mysite.com/user/foo-bar改写为/user?name=foo-bar。
这是我尝试过的:
Options +MultiViews
RewriteEngine On
RedirectMatch ^user/?$ /
RewriteRule ^user/(.+)$ user?name=$1
但是mysite.com/user 不会重定向,像mysite.com/user/foo-bar 这样的页面也没有查询字符串数据。
【问题讨论】:
标签: regex apache .htaccess mod-rewrite url-rewriting