开发者

Redirect all requests but one

开发者 https://www.devze.com 2023-03-05 12:22 出处:网络
I wonder how to redirect all requests like foobar.com/cat foobar.com/cat/1 foobar.com/etc to 开发者_运维问答foobar.com/index.php

I wonder how to redirect all requests like

foobar.com/cat
foobar.com/cat/1
foobar.com/etc

to

开发者_运维问答foobar.com/index.php

But not to affect

foobar.com/webmaster/

I don`t want foobar.com/webmaster/ to redirect to index.php. I want it default behavior

How to do that with mod_rewrite?


RewriteEngine on

RewriteRule ^webmaster/ - [QSA,L]
RewriteRule .* index.php [QSA,L]


try this foobar.com/(?!webmaster)[\w\/\d\_\-\:\;\?\=\.]+ as your regular expression to match all other except foobar.com/webmaster/

Apply this regex to select all except foobar.com/webmaster/ and match with

foobar.com/cat
foobar.com/cat/1
foobar.com/etc

add replace with

foobar.com/index.php
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号