Php htaccess将所有url重定向到相同的位置,但以暂存开头的位置除外
我想将所有url重定向到一个静态页面,除了包含暂存的页面 例如 base_url应位于/static/index.html 但是: base\u url/anything应重定向到/f/w/anythingPhp htaccess将所有url重定向到相同的位置,但以暂存开头的位置除外,php,apache,.htaccess,redirect,Php,Apache,.htaccess,Redirect,我想将所有url重定向到一个静态页面,除了包含暂存的页面 例如 base_url应位于/static/index.html 但是: base\u url/anything应重定向到/f/w/anything RewriteCond %{REQUEST_URI} !^staging RewriteRule ^(.*) static/index.html [L] 您可以在重写规则本身中使用否定: RewriteRule !^staging static/index.html [L,NC] 顺便说
RewriteCond %{REQUEST_URI} !^staging
RewriteRule ^(.*) static/index.html [L]
您可以在
重写规则
本身中使用否定:
RewriteRule !^staging static/index.html [L,NC]
顺便说一句,RewriteCond%{REQUEST_URI}应该有一个起始斜杠,所以条件应该是:
RewriteCond %{REQUEST_URI} !^/staging
更新:根据编辑的问题,您可以执行以下操作:
RewriteEngine on
# landing page
RewriteRule ^/?$ static/index.html [L]
# other URLs
RewriteRule !^f/w/ f/w%{REQUEST_URI} [L,NC]
您可以在
重写规则
本身中使用否定:
RewriteRule !^staging static/index.html [L,NC]
顺便说一句,RewriteCond%{REQUEST_URI}应该有一个起始斜杠,所以条件应该是:
RewriteCond %{REQUEST_URI} !^/staging
更新:根据编辑的问题,您可以执行以下操作:
RewriteEngine on
# landing page
RewriteRule ^/?$ static/index.html [L]
# other URLs
RewriteRule !^f/w/ f/w%{REQUEST_URI} [L,NC]
谢谢你的回答。我该怎么做才能在base_url上显示静态页面,而其他页面应按原样工作?您的意思是要显示
http://domain.com/
only并保持其他url不变?是的,这就是我想要的,其他人将使用base\u url/任何内容都应重定向到/f/w/anythingtanks以获得您的答案。我该怎么做才能在base_url上显示静态页面,而其他页面应按原样工作?您的意思是要显示http://domain.com/
only并保持其他url不变?是的,这就是我想要的,其他将使用base\u url/任何内容都应重定向到/f/w/anything