apache - 重定向每个页面,无论嵌套多深到同一域上的单个页面
问题描述
我已经看到了几个答案,但它们似乎都不适用于子目录或嵌套 URL。
基本上,我想将域上的所有内容重定向到同一个域上的“站点关闭”或“维护”页面,无论是使用直接 URL 还是目录指定,无论嵌套多深。
例如,所有这些:
example.com
example.com/page.html
example.com/sub
example.com/sub/page.html
example.com/sub/sub2
example.com/sub/sub2/page.html
...应该重定向到https://example.com/index_closed.html
我可以让它在 example.com 上工作,但不能在嵌套目录上工作。
此外,如果可能,它不应该重定向 .css 文件。谢谢!
解决方案
我发现以下工作:
RewriteCond %{REQUEST_URI} !/index_closed.html$
RewriteCond %{REQUEST_URI} !.css$ [NC]
RewriteCond %{REQUEST_URI} !.jpg$ [NC]
RewriteRule $ /index_closed.html [R=302,L]
推荐阅读
- c++ - pthread_join 期间的分段错误
- angularjs - 验证时的剑道多选问题
- java - 错误:不兼容的类型:
> 无法转换为 OnCompleteListener 错误 - php - PHP 数组插入无法按预期工作
- php - App\city_cost 类的对象无法转换为 int
- html - 如何为彼此输入的文本着色?
- javascript - 使用 jQuery在标记之前的锚标记内添加标记
- python - 尝试将 JSON 保存到文件但收到 AttributeError:“str”对象没有属性“dumps”
- ios - 导出 ipa 文件失败
- android - 片段声明的目标片段不属于此 FragmentManager - Android