简体   繁体   中英

htaccess redirect all url to same location except one starting with staging

I want to redirect all url to one static page except for one that contains staging

for eg

base_url shoud land to /static/index.html

but:

base_url/anything should redirect to /f/w/anything

RewriteCond %{REQUEST_URI} !^staging
RewriteRule ^(.*) static/index.html [L]

You can use negation in RewriteRule itself:

RewriteRule !^staging static/index.html [L,NC]

btw RewriteCond %{REQUEST_URI} should have a starting slash so you condition should be:

RewriteCond %{REQUEST_URI} !^/staging

Update: Based on edited question you can do:

RewriteEngine on

# landing page
RewriteRule ^/?$ static/index.html [L]

# other URLs
RewriteRule !^f/w/ f/w%{REQUEST_URI} [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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