我正在尝试将我的IP地址和Dynu域重定向到我的实际域。
这目前有效:
# Rewrite Rules
RewriteEngine On
RewriteCond %{HTTP_HOST} !^muffy.northernia.com$
RewriteRule ^(.*)$ http://muffy.northernia.com/$1 [L,R=301]
1) 用户试图访问我的公共IP(155.4.32.16),他们被重定向到muffy.northernia.com.
2) 用户试图访问我的Dynu域(e191374.Dynu.net),他们被重定向到muffy.northernia.com.
现在问题开始了:
当用户被重定向时,Apache会添加两个斜杠,而我无法删除它们。示例:我访问155.4.32.16/admin/nologo,它将我重定向到muffy.northnia.com//admin/nologo。注意这两个斜杠。
RewriteCond %{REQUEST_URI} ^(.*)//+(.*)$
RewriteRule / http://muffy.northernia.com/%1/%2 [R=301,L]
我做错了什么?
解决了它。默认情况下,"$1"包含索引路径"/"。
更改:
RewriteRule ^(.*)$ http://muffy.northernia.com/$1 [L,R=301]
收件人:
RewriteRule ^(.*)$ http://muffy.northernia.com$1 [L,R=301]
我为dynu编写的API包装器可能对您有用:https://github.com/adm-github/godynu