【问题标题】:.htaccess - How to redirect all urls to url.php except index.php.htaccess - 如何将所有 url 重定向到 url.php,除了 index.php
【发布时间】:2012-11-28 16:09:34
【问题描述】:
RewriteEngine On    # Turn on the rewriting engine
RewriteRule    .    url.php    [NC,L]    

我将所有请求重定向到 url.php 但我想保留 index.php 原样。

【问题讨论】:

  • 所有 endline cmets 都会生成错误,并将用警告填充错误日志。不要将 cmets 放在任何指令或任何行的末尾。这种变化发生在 Apache 1.3.x 中,将 cmets 放在了自己的行中。

标签: php .htaccess


【解决方案1】:
# Turn On ReWrite Engine
RewriteEngine On

# Exclude url.php and index.php from redirecting
RewriteCond %{REQUEST_URI} !^/(index|url)\.php

# Redirect to url.php
RewriteRule . url.php [NC,L]

【讨论】:

    【解决方案2】:

    这样就可以了:

    RewriteEngine On    # Turnon the rewriting engine
    RewriteRule ^/index\.php$ - [L]
    RewriteRule    .    url.php    [NC,L] 
    

    【讨论】:

    • 我相信这应该放在 OP 现有的 RewriteRule 之前。
    【解决方案3】:

    内部服务器错误

    服务器遇到内部错误或配置错误,无法完成您的请求。

    请联系服务器管理员并告知他们错误发生的时间,以及您在此错误之前执行的操作。

    服务器错误日志中可能会提供有关此错误的更多信息。

    【讨论】:

      猜你喜欢
      • 2019-11-29
      • 2016-11-30
      • 1970-01-01
      • 2013-08-26
      • 2016-11-30
      • 1970-01-01
      • 2016-07-29
      • 2013-01-21
      • 2015-04-10
      相关资源
      最近更新 更多