RewriteCondition rewriteRule 如何使所有流量直接到单个文件?
亲爱的朋友们,
想象一个单页网站
RewriteCond %{HTTP_HOST} ^1pagesite.org$
RewriteRule ^$ 1pagesite.php [L]
目前,主页确实正确显示了 1pagesite.php。
但是,当请求另一个文件时,比如确实在服务器上的 test.php,会显示 test.php!,而我想指出所有和任何目前流量流向 1pagesite.php。如何做到这一点,以便在该域之后没有其他文件或文件夹/文件或任何内容出现,并且所有内容都定向到 1pagesite.php?
非常感谢您提供解决此难题的提示和建议。干杯,萨姆
Dear folks,
Imagine a One Page Site
RewriteCond %{HTTP_HOST} ^1pagesite.org$
RewriteRule ^$ 1pagesite.php [L]
Currently, the home page does present the 1pagesite.php correctly.
However, when another file is requested say, test.php which is on the server indeed, that test.php is shown!, while I would like to point ALL and ANY trafic towards 1pagesite.php for the time being. How to make this happen sothat no other file or folder/file or anything after this domain is presented and everything is directed towards 1pagesite.php?
Thanks very much for hints and suggestions to solve this puzzle. Cheers, Sam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
注意:这仅将请求重定向到 .html 和 .php 页面
Note: This redirects only request to .html and .php pages
你可以尝试这个规则:
仅将 php 和 html 页面重定向到 1pagesite.php
Can you try this rule:
to redirect only php and html pages to 1pagesite.php
您的重定向仅匹配
^$
,也就是说仅匹配根页面(空字符串)。因此每个请求都会被重定向到 1pagesite.php 页面(图像、CSS,...正如 Sander 所说)。
如果您需要过滤某些内容,您可以添加一个
以启用 / 目录中的 .css 和 .jpg 文件。这可以为其他子目录文件等定制...
Your redirection only match
^$
that is to say only the root page (empty string).So every request will be redirected to 1pagesite.php page (images, css, ... as Sander said).
If you need to filter some content you can add a
to enable .css and .jpg file from your / directory to be served. This can be customized for other subdirecories files etc...