apache mod_rewrite 用于自动发现 url

标签 apache mod-rewrite url-rewriting

我正在为 mod_rewrite 苦苦挣扎。

我想重写此模式的所有 URL:

[aA][uU][tT][oO][dD][iI][sS][cC][oO][vV][eE][rR].*/UrL/aNy/paTh

这也许

auToDiscoveR.example1.com/UrL/aNy/paTh
AUtoDiscoveR.example2.cn/UrL/aNy/paTh
autodiscover.anything.anytld/UrL/aNy/paTh

到 URL

autodiscover.mydomain.com/url/any/path

意味着我必须替换 DNS/主机名并将完整的限定 URL 改为小写。但是如何在 mod_rewrite 中做到这一点呢?

最佳答案

您问题的正确答案很大程度上取决于您的虚拟主机的设置方式。这个配方在正确的配置中是正确的。

RewriteEngine On
RewriteMap lc int:tolower
RewriteCond %{HTTP_HOST} !^autodiscover\.mydomain\.com$ [OR]
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) http://autodiscover.mydomain.com${lc:$1} [R,L]

关于apache mod_rewrite 用于自动发现 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28744376/

相关文章:

post - nginx 重写 POST 请求

php - 从每种类型中选择 X 项

apache - tomcat7在ubuntu上自动停止

.htaccess - 删除 index.php,强制 ssl,并将 www 重定向到 .htaccess 中的非 www

apache - Laravel 5 Apache mod_rewrite 不工作

redirect - 如何在 Nginx 中重定向 URL

apache - 多个 .htaccess 文件中多个 mod_rewrite 规则的优先级是什么?

django - 无效的命令 'WSGIScriptAlias' ,可能拼写错误或由未包含在服务器配置中的模块定义

linux - catalina.out 中有很多(权限被拒绝)

Apache:强制使用 404 状态代码