.htaccess-如何将除index.php之外的所有url重定向到url.php

.htaccess-如何将除index.php之外的所有url重定向到url.php,php,.htaccess,Php,.htaccess,我正在将所有请求重定向到url.php,但我想保持index.php不变 这样就可以了: RewriteEngine On # Turn on the rewriting engine RewriteRule . url.php [NC,L] 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求 请与服务器管理员联系,并通知他们错误发生的时间,以及在此错误发生之前执行的操作 有关此错误的详细信息可在服务器错误日志中找到。我认为这应该放在OP现有的重写规

我正在将所有请求重定向到url.php,但我想保持index.php不变

这样就可以了:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    .    url.php    [NC,L]    
内部服务器错误

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

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


有关此错误的详细信息可在服务器错误日志中找到。

我认为这应该放在OP现有的重写规则之前。所有的结束行注释都会生成错误,并会在错误日志中填入警告。不要将注释放在任何指令或任何行的末尾。这一变化发生在Apache1.3.x中,将注释放在自己的行上。
RewriteEngine On    # Turnon the rewriting engine
RewriteRule ^/index\.php$ - [L]
RewriteRule    .    url.php    [NC,L] 
# 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]