【问题标题】:Redirect in .htaccess doesn't work for url existing.htaccess 中的重定向不适用于现有的 url
【发布时间】:2018-04-05 19:06:43
【问题描述】:

我创建了一个 .htaccess 来将所有 url 重定向到 index.php 它适用于不存在的 url,但对于其他 url(存在)它不起作用,我不知道为什么。 Isearch & 我尝试了所有配置,但似乎不起作用。

这是我的 .htaccess :

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

谁有办法?

【问题讨论】:

    标签: .htaccess redirect url-redirection


    【解决方案1】:

    这是因为您的 RewriteConds 不允许现有的链接和目录转到 /index.php 。如果你想重定向所有传入的请求(现有的或不存在的),你可以使用以下:

    RewriteEngine on
    
    RewriteRule !index.php /index.php [L]
    

    另见:Redirect all to index.php htaccess

    【讨论】:

      猜你喜欢
      • 2018-08-18
      • 1970-01-01
      • 2014-10-28
      • 1970-01-01
      • 2017-03-18
      • 2018-06-20
      • 2014-06-11
      • 1970-01-01
      • 2021-10-10
      相关资源
      最近更新 更多