Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

apache - Htaccess not redirecting to new base

I would like to redirect anything that does not begin with /X, to /X, and, I'm trying to do this by using .htaccess with this content:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(?!/X)
RewriteRule ^(.*)$ /X/$1

What am I missing?

EDIT:
I've also tried:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/X
RewriteRule ^(.*)$ /X/$1 [L]

and using this tool seems like it should work, but for example www.site.com/style.css

It's now working...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have it like this:

RewriteEngine On

RewriteCond %{THE_REQUEST} !s/+alsiniga/X[/?s] [NC]
RewriteRule ^ /alsiniga/X%{REQUEST_URI} [L,R=301,NE]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...