Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess将所有url重定向到相同的位置,但以暂存开头的位置除外_Php_Apache_.htaccess_Redirect - Fatal编程技术网

Php htaccess将所有url重定向到相同的位置,但以暂存开头的位置除外

Php 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] 顺便说

我想将所有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}应该有一个起始斜杠,所以条件应该是:

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