简体   繁体   English

htaccess将所有url重定向到同一位置,但其中一个以暂存开始

[英]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 我想将所有url重定向到一个静态页面,但其中包含暂存页面

for eg 例如

base_url shoud land to /static/index.html base_url应该登陆/static/index.html

but: 但:

base_url/anything should redirect to /f/w/anything base_url / anything应该重定向到/ f / w / anything

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

You can use negation in RewriteRule itself: 您可以在RewriteRule本身中使用否定:

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

btw RewriteCond %{REQUEST_URI} should have a starting slash so you condition should be: btw RewriteCond %{REQUEST_URI}应以斜杠开头,因此您的条件应为:

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]

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

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