htaccess的 - 如何重定向所有的URL url.php除了index.php文件 [英] .htaccess - How to redirect all urls to url.php except index.php

查看:312
本文介绍了htaccess的 - 如何重定向所有的URL url.php除了index.php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  RewriteEngine叙述在#打开重写引擎
重写规则。 url.php [NC,L]
 

我重定向所有url.php的请求,但我想离开的index.php原样。

解决方案

 #打开重写引擎
RewriteEngine叙述上

#排除url.php和index.php文件从重定向
的RewriteCond%{REQUEST_URI} ^ /!(指数| URL)\ PHP

#重定向到url.php
重写规则。 url.php [NC,L]
 

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.

解决方案

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

这篇关于htaccess的 - 如何重定向所有的URL url.php除了index.php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆