dongyan7950 2016-12-12 11:08
浏览 206
已采纳

Apache,.htaccess,多索引页面

I want to a file which executed at EVERY request, lets say index.php

RewriteRule ^(.*)$ index.php [QSA]

however, if it happens to have index2.php, lets rather execute that file. In other words, if index2.php exists, it overrides the default behaviour. So I would write this:

RewriteRule ^(.*)$ index2.php [QSA]
RewriteRule ^(.*)$ index.php [QSA]

but if index2.php doesnt exists, it fails

RewriteRule ^(.*)$ index2.php [L]
RewriteRule ^(.*)$ index.php [L]

this way too. Index2.php doesnt need to be exists, but index.php does and will always be

  • 写回答

1条回答 默认 最新

  • douhan8581 2016-12-12 11:10
    关注

    You can add a condition, and apply the RewriteRule only when index2.php exists.

    RewriteCond %{DOCUMENT_ROOT}/index2.php -f
    RewriteRule ^(.*)$ index2.php [QSA,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog