.htaccess将子文件夹重定向到其他域

时间:2017-09-07 13:58:33

标签: apache .htaccess redirect

我最近搬到了另一台服务器,但是一个iframe暂时需要服务器来自旧服务器。我需要重定向

http://example.com/iframe/ *

http://123.456.789.012/iframe/ *

在我尝试的example.com/iframe/.htacces中

RewriteCond %{REQUEST_URI} /iframe/(.*)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://123.456.789.012/$1 [L,R=302]

RewriteRule iframe/(.*)$  http://123.456.789.012/iframe/$1 [R=301,NC,L]

(等等)都失败了。

编辑:

  1. .htaccess被定义解析。文件中的垃圾呈现HTTP 500
  2. 当我在新服务器上创建一个简单的文本文件时,我可以打开它 - 所以至少URL指向它所属的位置
  3. 我错过了什么? 感谢

1 个答案:

答案 0 :(得分:1)

example.com/iframe/.htacces

中有此规则
RewriteEngine On

RewriteCond %{HTTP_HOST} !=123.456.789.012
RewriteRule ^(.*)$ http://123.456.789.012/iframe/$1 [L,R=302,NE]

在完全清除浏览器缓存后对其进行测试。

相关问题