Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache 如何使用.htaccess将不存在的页面从特定文件夹重定向到主页?_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache 如何使用.htaccess将不存在的页面从特定文件夹重定向到主页?

Apache 如何使用.htaccess将不存在的页面从特定文件夹重定向到主页?,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我有一个名为mydomain.com/node的目录,在这个目录下,有很多不存在的页面,比如node/5678 node/53322等等。当用户访问这些不存在的页面时,我想将它们重定向到主页,即mydomain.com 请注意,node/下也有许多有效页面,但我只想重定向node/下不存在的页面/ 我试过以下两种,但都不适合我 RewriteCond %{REQUEST_URI} !^/node/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %

我有一个名为mydomain.com/node的目录,在这个目录下,有很多不存在的页面,比如node/5678 node/53322等等。当用户访问这些不存在的页面时,我想将它们重定向到主页,即mydomain.com

请注意,node/下也有许多有效页面,但我只想重定向node/下不存在的页面/

我试过以下两种,但都不适合我

RewriteCond %{REQUEST_URI} !^/node/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA]


RewriteCond  %{REQUEST_URI} !^/node/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule   ^(.+)         mydomain.com [R=301,L]
如有任何建议,将不胜感激