regex - htaccess 正则表达式匹配用户名 url
问题描述
我需要在 url 中使用用户名
domain.com/用户名
所以我把这一行作为 htaccess 中的最后一行,以避免与其他页面发生冲突。
RewriteRule ^([a-zA-Z0-9.]+)/?(i.html)?$ index.php?module=profile&username=$1 [QSA,L]
但问题是当我请求domain.com/manage/并继续到最后一行时,下面的行被忽略了,这导致了冲突。
RewriteRule ^manage/?(i.html)?$ manage.php?module=manage [QSA,L]
有没有办法让最后一个模式做到这一点:
/ (staticname|或任何其他静态页面的名称|) /i.html =不正常
/ fstaticname /i.html = OK作为用户名
/ staticnamef /i.html = OK作为用户名
/staticname.f /i.html = OK作为用户名
/ staticname = OK作为用户名
如果没有,还有其他解决方案吗?
谢谢你!
编辑 :
我得到这个正则表达式
^((?!(manage|notifs|admin)\/?$)([a-zA-Z0-9.]+))\/?(i.html)?$
它在正则表达式测试器中工作正常,但不适用于 htaccess。
解决方案
推荐阅读
- python - Sphinx 文档创建期间的扩展错误
- excel - 计算数组中的匹配,重复一次
- godot - 标识符未在 godot 的当前范围内声明
- javascript - 在不使用 startDate 和 endDate 的情况下禁用引导日期选择器中的未来日期
- ios - 在 Xcode 13 [[UINavigationBar 外观] setBarTintColor: 无法正常工作?
- c# - C# 创建 Active Directory 用户 - 异常未知错误 (0x80005000)
- r - (R) 如果另一列中唯一的结果匹配是 NA,则根据字符串名称过滤行
- r - 基于另一个数据帧的数据帧中的字符串替换
- reactjs - 弹出后无法启动 React 开发服务器
- bash - bash 文本处理以删除 ascii 并从结果中获取唯一行