我的情况,我需要将所有请求匹配http://mywebsite.com/portfolio/[anyname]
到http://mywebsite.com/portfolio.php?username=[anyname]
.任何人都可以帮我写.htaccess文件.
谢谢
您可以通过以下简单规则逃脱:
RewriteEngine On
RewriteRule ^portfolio/(\w+)$ portfolio.php?username=$1 [L]
Run Code Online (Sandbox Code Playgroud)
如果用户名可以包含除字母之外的任何内容,请使用.+
而不是\w+
其他选项记录在http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html下