【发布时间】:2018-08-15 13:25:47
【问题描述】:
我想要又短又甜。我的网址是这个
https://www.example.com/ABCD/index.php
为了方便用户,我把ABCD目录改成了abcd(小写)。现在用户输入
https://www.example.com/abcd/index.php
但是,如果用户从 google 访问我的网站,它仍然会被缓存为
https://www.example.com/ABCD/index.php
因此他们无法登录。
我搜索了谷歌和堆栈溢出,我发现最接近的有效是 [这里].1 即
在 http.conf 中
<IfModule mod_rewrite.c>
RewriteMap lc int:tolower
</IfModule>
在 .htaccess 中
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]
但是在我的情况下它也不起作用。因为它把用户从
https://www.example.com/ABCD/index.php?gene=MYH7
致 https://www.example.com/var/www/html/example.com/?gene=MYH7
有经验的人可以帮我纠正这个规则。我想要的只是引导用户
https://www.example.com/abcd/index.php
如果他们输入 https://www.example.com/ABCD/index.php
这是我的网络根目录中的 .htaccess。
RewriteEngine On
# Added by Mian to direct all traffic to https
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.example.org%{REQUEST_URI} [NE,L,R]
# Added by Mian for url capital to small.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]
【问题讨论】:
-
确实又短又甜。
标签: regex linux apache web-services