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
Apache 为什么这不起作用,htaccess,捕获域ext并在cond中使用_Apache_.htaccess_Rewrite - Fatal编程技术网

Apache 为什么这不起作用,htaccess,捕获域ext并在cond中使用

Apache 为什么这不起作用,htaccess,捕获域ext并在cond中使用,apache,.htaccess,rewrite,Apache,.htaccess,Rewrite,为什么这个重写规则不起作用 RewriteCond %{HTTP_HOST} domain.(se|dk)/shop/$ [NC] RewriteRule ^ https://domain.$1 [R=302,L,NE] 我正在尝试捕获对domain.dk/shop/和domain.se/shop/的所有请求,并将它们重定向到domain.dk或domain.se 有什么问题吗 整个htaccess <IfModule mod_rewrite.c> Options +FollowS

为什么这个重写规则不起作用

RewriteCond %{HTTP_HOST} domain.(se|dk)/shop/$ [NC]
RewriteRule ^ https://domain.$1 [R=302,L,NE]
我正在尝试捕获对domain.dk/shop/和domain.se/shop/的所有请求,并将它们重定向到domain.dk或domain.se

有什么问题吗

整个htaccess

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# Redirect everything to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTP_HOST} domain.(se|dk)$ [NC]
RewriteRule ^shop$ https://domain.%1/ [R=302,L,NE]

</IfModule>
HTTP_主机没有任何路径信息,它只是domain.se。路径信息必须在规则的正则表达式匹配中:

RewriteCond %{HTTP_HOST} domain.(se|dk)$ [NC]
RewriteRule ^shop$ https://domain.%1/ [R=302,L,NE]

此外,还需要使用%1反向引用,它引用条件中的一个分组。$1 backreference是规则分组中没有的一个。

ah,但我假设这是一个条件,无论如何,当我访问domain时它不起作用。se/shop/我没有被重定向到domain.se,我可以发布整个htaccess。url最后必须有一个反斜杠,我尝试了RewriteRule^shop/$[R=302,L,NE]也不work@IvanRistic在你的wordpress路由规则之前,你需要你的最后2条规则。否则,所有的路由首先发生,您将永远无法匹配/shop/。