【问题标题】:redirect only domain.com to domain.com/subfolder/index.php not domain/whatever仅将 domain.com 重定向到 domain.com/subfolder/index.php 而不是 domain/whatever
【发布时间】:2014-08-07 00:26:06
【问题描述】:

如果用户请求现有的 php 代码,我将其放在根目录中:

  • domain.com/images/pic1.jpg
  • domain.com/anyphp.php
  • domain.com/someapp/somecode.php
  • domain.com/anything.someExt

什么都别做,就这样吧,他们工作得很好。

但如果他只是输入 domain.com -> 将他发送到 domain.com/myNewApp/index.php,这是我很酷的新应用程序。不要将 URL 重写为 domain.com/index.php,因为它是针对我现有的应用程序的。

我希望答案可能非常简单,但我只是放弃尝试

【问题讨论】:

    标签: apache .htaccess redirect oxwall


    【解决方案1】:

    DirectoryIndex oxwall/index.php

    简单但有效

    【讨论】:

      【解决方案2】:

      您可以访问 Apache conf 文件吗?如果是这样:

      RewriteEngine  on
      RedirectMatch ^/(.*)$ http://example.com/myNewApp/index.php
      

      应该可以。

      编辑:此重写不起作用。我从未使用过正则表达式捕获。我误读了你想要的。看起来您找到了答案,但如果您将正则表达式更改为:

      RewriteEngine  on
      RedirectMatch ^/$ http://example.com/myNewApp/index.php
      

      查看此页面以获得更多可重写的优点: http://httpd.apache.org/docs/current/rewrite/remapping.html

      【讨论】:

      猜你喜欢
      • 2013-02-14
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多