【问题标题】:htaccess File - How to redirect to a certain link but not to website?htaccess 文件 - 如何重定向到某个链接而不是网站?
【发布时间】:2019-02-26 09:19:55
【问题描述】:

假设我有http://example.com 作为我的网站。

现在,当我执行http://example.com/api/login 时,登录脚本可以正常工作。

但是当我执行http://example.com 时,它直接进入我的路由器设置中的默认开关原因,在 htaccess 文件中为 index.php 显示回显访问被拒绝。 无论哪种情况,它都不会显示网站。

所有文件都在 public_html 文件夹中用于托管。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]

那是我当前的 htaccess 文件。我该怎么做才能解决这个问题?

【问题讨论】:

    标签: php html apache .htaccess hosting


    【解决方案1】:

    您的基本文件夹的内容是什么?默认情况下,如果您想前往登录页面,php 将始终打开 index.php 文件,而不是在您的情况下为 http://example.com/api/login 然后编辑您的 index.php 文件以使用

    重定向到它
      die(header("location: http://example.com/api/login"));
    

    放置在 index.php 脚本的顶部

    【讨论】:

      【解决方案2】:

      我通过在 public_html 中创建一个名为 backend 的新文件夹来修复它 我将 htaccess 更改为

      RewriteEngine On
      RewriteBase /backend/
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.+)$ index.php [QSA,L]
      

      我将所有与后端相关的东西都放在那里,现在可以使用了

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-26
        • 2018-04-27
        • 2012-11-14
        相关资源
        最近更新 更多