简体   繁体   English

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

[英].htaccess - How to redirect all urls to url.php except index.php

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    .    url.php    [NC,L]    

I'm redirecting all the requests to url.php but I want to leave index.php as is. 我正在将所有请求重定向到url.php,但我想保留index.php。

# 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]

This'll do the trick: 这就行了:

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

Internal Server Error 内部服务器错误

The server encountered an internal error or misconfiguration and was unable to complete your request. 服务器遇到内部错误或配置错误,无法完成您的请求。

Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error. 请与服务器管理员联系,告知他们错误发生的时间以及您在此错误发生之前执行的操作。

More information about this error may be available in the server error log. 服务器错误日志中可能提供了有关此错误的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM