Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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/6.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
Regex HTACCESS,不在特定页面上_Regex_.htaccess_Mod Rewrite_Routing - Fatal编程技术网

Regex HTACCESS,不在特定页面上

Regex HTACCESS,不在特定页面上,regex,.htaccess,mod-rewrite,routing,Regex,.htaccess,Mod Rewrite,Routing,我想检查用户是否通过以下URL之一进入网站 (en|nl|fr|de|es|pl|sv|it|cs|el|fi|hu)/(home|business|product|contact|faq|gallery|videos|locator) 否则,我想将用户重定向到404页面 我试过这个: RewriteRule !^((en|nl|fr|de|es|pl|sv|it|cs|el|fi|hu)/(home|business|product|contact|faq|gallery|videos|lo

我想检查用户是否通过以下URL之一进入网站

(en|nl|fr|de|es|pl|sv|it|cs|el|fi|hu)/(home|business|product|contact|faq|gallery|videos|locator)
否则,我想将用户重定向到404页面

我试过这个:

RewriteRule !^((en|nl|fr|de|es|pl|sv|it|cs|el|fi|hu)/(home|business|product|contact|faq|gallery|videos|locator)|404)$ /404 [L,R=307]
但这给了我一个路由循环

有什么办法解决这个问题吗?

用这个:

RewriteCond %{REQUEST_FILENAME} !^404|(?:css|js|jpg|gif|png)$ [NC]
RewriteRule !^(en|nl|fr|de|es|pl|sv|it|cs|el|fi|hu)/(home|business|product|contact|faq|gallery|videos|locator) - [L,R=404]

这似乎奏效了。但是,现在,我的所有图像/css/脚本都没有正确加载,它们位于/uploads目录中。我添加了一个条件,这样我们就不会有404个文件以
css
等结尾。如果需要,您知道如何添加扩展名。让我知道这是否有效。:)顺便说一句,如果您仍然使用404,请尝试其他浏览器,因为您的浏览器可能已缓存404或清除缓存。哦,最后一件事,我有一个自定义404页面。这就是为什么我首先路由到/404。但是,我得到了一个无限循环,因为404页不在例外中。很抱歉打扰你,htaccess对我来说都是非常非常新的:)+1持续支持以帮助OP@ThomasdeRoo:如果你发布完整的.htaccess,它总是有帮助的。