我实际上正在为学校工作,我尝试使用.htaccess创建URL重写。
所以这是我在我的.htaccess中的代码
Options +FollowSymlinks
RewriteEngine on
RewriteRule profile/([0-9]+) profile/index.php?id=$1 [L]
RewriteRule profile/([a-zA-Z]+) profile/index.php?username=$1 [L]
我尝试使用 ID 或用户名创建重写,如果我删除最后一行,我的代码适用于数字,但如果使用永远不起作用的用户名。我不太擅长 url 重写,暂时学习。但是有可能这样做吗??
如果可能的话,我该怎么做?
Options +FollowSymlinks
RewriteEngine on
RewriteRule profile/([0-9]+)$ profile/index.php?id=$1 [L]
RewriteRule profile/([a-zA-Z]+)$ profile/index.php?username=$1 [L]
你忘了$。