regex - htaccess 删除国家变量
问题描述
抱歉,我找不到任何解决我的问题的方法。希望各位大神帮忙。
我有网址:
http://example.com/country-prefix/.well-known/other-part
我想把它变成:
http://example.com/.well-known/other-part
所以删除国家前缀,例如:
http://example.com/pl/.well-known/other-part => http://example.com/.well-known/other-part
http://example.com/us/.well-known/other-part => http://example.com/.well-known/other-part
仅当 /.well-known/ 在 url
我知道可以这样做:
RewriteCond %{REQUEST_URI} /.well-known/
RewriteRule ^/?(pl|eu)/(.*)$ $2
但是是否可以在 RewriteRule 中不包含所有语言前缀(因此它适用于所有语言),例如上面的示例适用于:
http://example.com/pl/.well-known/other-part
但不是为了
http://example.com/us/.well-known/other-part
解决方案
感谢:Sumurai8
如果有人需要它:
RewriteCond %{REQUEST_URI} /.well-known/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]+/(.*)$ $1
推荐阅读
- python - MultiCheckCombobox pyqt
- r - R - 具有相同概率的类的卡方独立性检验
- c# - 使用 jquery 为非常大的数据加载嵌套的 gridview
- node.js - 护照会话在 Nginx 代理后过期 - NodeJS
- html - 为什么选择属性
- spring - 使用单个 Connection / DataSource / SessionFactory / TransactionManager 休眠多个模式
- hyperledger - Hyperledger Sawtooth 在哪里存储其分类帐?
- c# - 如何在 C# 中编写 bat 脚本
- c++ - Metalog 所有日志都用 [kernel] 打印
- javascript - 直接在html中使用ES6模块中定义的函数