将 apache2 @username 的 URL 重写为 /user/username
这相当简单,但我很难弄清楚该怎么做,我在 apache2 rewriteurl 文档中进行了搜索,但没有找到任何有用的东西。 你转到 url.com/@myusername ,apache 会将你指向 url.com/username/@myusername 并在浏览器上保持 URL 完整,并带有 [L,NE,P]
RewriteURL @username /user/username
请注意,我只想重定向以 @ 符号开头的内容并将其作为用户名
This is fairly simple but I am having a hard time figuring out what to do I searched in the apache2 rewriteurl documentation but didnt find anything helpful.
you go to url.com/@myusername and apache points you to url.com/username/@myusername and keeps the URL on the browser intact with [L,NE,P]
RewriteURL @username /user/username
please note I only want to redirect what starts with @ sign and take it as a username
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先激活mod_rewrite,
sudo a2enmod rewrite
然后重新启动apache2,
sudo systemctl restart apache2
在Web根目录中创建.htaccess文件。这必须是您在 apache 配置中提供的文档根目录。
更新
如果您希望匹配以@符号开头,请使用如下正则表达式,
First activate mod_rewrite,
sudo a2enmod rewrite
Then restart apache2,
sudo systemctl restart apache2
create the .htaccess file in the web root. This must be the document root you provided in the apache config.
UPDATE
If you want the match start with @ symbol, use the regex as below,