我想要:www.example.com/username
重定向到:www.example.com/user.php?id=username
尝试使用我发现的这个 mod_rewrite 规则: RewriteRule ^user/([az]+)/?$ user.php?id=$1
我对此进行了很多研究,但仍然无法使其正常工作。我开始认为某处存在冲突……我不知道。我迷路了。
<VirtualHost 111.111.111.111.:443>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/public
<Directory /home/public>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
RewriteEngine On
RewriteRule ^user/([a-z]+)/?$ user.php?id=$1
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
</VirtualHost>