我有外部IP和主机名设置为我的机器。
I have external IP and hostname configured for my machine.
在应用程序中,我只使用域名访问的API。所以,当我尝试通过IP地址来访问我的API,它显示302移动暂时的错误。因此,请求(主页),点击IP地址的服务器上,它应该重定向到主机名。
Inside the application, I am using only the domain names to access the APIs. So when i try to access my APIs through IP address, it shows 302 Moved temporarily error. So, for request(for Homepage) that hits the server with IP address, It should redirect to hostname.
即,当用户点击的https://XX.XX.XX.XX/main 该应重定向到 ayz-abc.mysite/main
That is, when user hits XX.XX.XX.XX/main it should be redirected to ayz-abc.mysite/main
有关这一点,我使用重定向Apache中的httpd.conf中尝试。
For this I tried using the redirect in httpd.conf of apache.
<VirtualHost XX.XX.XX.XX> DocumentRoot "/var/www/html" #ServerName ayz-abc.mysite/ # Other directives here RewriteEngine On RewriteRule /.* ayz-abc.mysite/ [R] </VirtualHost>我也曾尝试用下面的
I have also tried with the following
<VirtualHost *.portnum> DocumentRoot "/var/www/html" RewriteEngine On RewriteCond %{HTTPS} on RewriteRule XX.XX.XX.XX/main ayz-abc.mysite/main [R=301,L] </VirtualHost>Plsssss帮助我。
Plsssss help me.
推荐答案确定。你缺少一个重写条件
Ok. You are missing a rewrite condition
<VirtualHost XX.XX.XX.XX> DocumentRoot "/var/www/html" #ServerName ayz-abc.mysite/ # Other directives here RewriteEngine On RewriteCond %{HTTP_HOST} !^ayz-abc.mysite$ RewriteRule /.* ayz-abc.mysite/ [R] </VirtualHost>如果您不包括这种情况下它甚至会与主机重定向
If you don't include this condition it will redirect even with the hostname
更多推荐
Apache的httpd.conf重定向IP到主机名
发布评论