.htaccess / https 重定向,虚拟文件夹访问(有例外)
/* 这似乎是我 10 天前问过的另一个问题的重复 (.htaccess / 重定向到 https://www.example.com 和虚拟文件夹访问),但是 (a) 我没有收到对我对问题所做的更改的任何回复,并且(b)这里的这个问题是上述问题的一个更复杂的版本,我相信需要一个新的查询*/
我有一个具有以下实体的网站: example.com/index.html example.com/main.php example.com/SPECIAL/main.php 除此之外,我还有 example.com/images/、/css/ 等文件夹,脚本生成的 html 指向这些文件夹。
我需要 .htaccess 魔法来实现以下所有功能:
(a) 将用户从“example.com”永久重定向到“www.example.com”(301 内容)
(b) 将用户从 http://www.example.com 永久重定向到 https://www.example.com(301 内容)
(c) 访问 example.com/ 的用户当然应该看到 index.html,但如果他们输入
example.com/ABCDEF OR
; example.com/ABCDEF/
它们应该被重定向到 example.com/main.php?folder=ABCDEF
除非 ABCDEF 是一个真实的文件夹(如 /SPECIAL/、/images/、 /css/等)
(d) 如果用户尝试访问 example.com/REALFOLDER/(例如 /images/),他应该被重定向到 example.com/
(e) 所有这些都不应该干扰 example.com/index.html
的查看
抱歉,如果这听起来很复杂,但这正是我所需要的!
S
/* THIS would appear to be a duplicate of another question I had asked 10 days back (.htaccess / redirecting to https://www.example.com and virtual folder access), but (a) I didnt get any responses to the changes I made to the question, and (b) this question here is a more complex version of the above and I believe warrants a new query */
I have a site which has the following entities:
example.com/index.html
example.com/main.php
example.com/SPECIAL/main.php
besides the above, I have folders like example.com/images/, /css/, etc which the html generated by the scripts point to.
I need .htaccess magic for ALL of the below:
(a) permanently redirecting users from "example.com" to "www.example.com" (301 stuff)
(b) permanently redirecting users from http://www.example.com to https://www.example.com (301 stuff)
(c) users accessing example.com/ should, of course, see index.html, but if they type
example.com/ABCDEF OR
example.com/ABCDEF/
they should be redirected to example.com/main.php?folder=ABCDEF
EXCEPT when ABCDEF is a real folder (like /SPECIAL/, /images/, /css/, etc)
(d) If user tries to access example.com/REALFOLDER/ (eg /images/), he should just be redirected to example.com/
(e) All of this should not mess with the viewing of example.com/index.html
Sorry if this sounds complex, but thats exactly what I need!
S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这些规则:
Try these rules: