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
.htaccess Htaccess将域移动到子文件夹_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess Htaccess将域移动到子文件夹

.htaccess Htaccess将域移动到子文件夹,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我想在.htaccess中添加一些规则,以实现以下目标: domain.com/(*)=>domain.nl/en/$1 domain.de/(*)=>domain.nl/de/$1 domain.nl停留domain.nl 我一直在寻找,现在还没有找到任何解决方案,帮助我正确。这当然很容易 目前获得: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com [NC] Rew

我想在.htaccess中添加一些规则,以实现以下目标:

  • domain.com/(*)
    =>
    domain.nl/en/$1
  • domain.de/(*)
    =>
    domain.nl/de/$1
  • domain.nl
    停留
    domain.nl
我一直在寻找,现在还没有找到任何解决方案,帮助我正确。这当然很容易

目前获得:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://domain.nl/en/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.de [NC]
RewriteRule ^(.*)$ http://domain.nl/de/$1 [R=301,L]

</IfModule>

你应该可以这样做

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^(.*)$ http://domain.nl/en/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.de [NC]
RewriteRule ^(.*)$ http://domain.nl/de/$1 [R=301,L]

谢谢但这给了我一个500的误差。。我看不出你的代码有错误,尽管很抱歉。打字错误。再试一次,还是不适合我。更新了我上面的问题。我通过每次打开一个匿名窗口进行测试,这样可以清除任何浏览器缓存。不,抱歉,只是不重定向。您在同一台服务器上有这些域,并且正确配置了vhost以指向那里吗?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteRule ^(.*)$ http://domain.nl/en/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.de [NC]
RewriteRule ^(.*)$ http://domain.nl/de/$1 [R=301,L]