如何在centos上使用httpd时重定向url 7
问题描述:
我在我的项目中使用react-routers。我使用webpack来打包我的JavaScript代码。但是当我在linux 7的服务器上运行我的项目时,它出现了一些问题。我试过http://116.xx.xx.xx,效果很好。但是当我尝试http://116.xx.xx.xx/login时,它找不到URL,因为它试图找到var/www/html/myproject/login/index.html而不是使用react-router。顺便说一下,该项目运行在80端口,我使用httpd来提供服务。所以我想这是我的httpd.conf有错误。我想知道如何重定向/登录到index.html。如何在centos上使用httpd时重定向url 7
答
也许你可以使用Apache模块(mod_alias中):
文件:httpd.conf中
重定向域名:
Redirect/http://www.new-domain.com/
或
Redirect permanent/http://www.new-domain.com/
重定向页面:
Redirect /web-page.html http://www.new-domain.com/destination-web-page.html
注:
- 重定向指令优先于Alias和ScriptAlias指令 指令。
- 其他“重定向”选项包括:temp(错误302)默认 - 临时重定向状态,seeother(错误303)资源已被 替换并消失(错误410)资源已被永久删除。
实施例的httpd.conf与多个域的虚拟主机其中所有重定向:
<VirtualHost XXX.XXX.XXX.XXX>
ServerName directtolinux.com
ServerAlias www.directtolinux.com
ServerAlias direct-to-linux.com
ServerAlias www.direct-to-linux.com
ServerAlias digitalpenguins.com
ServerAlias www.digitalpenguins.com
Redirect permanent/http://www.yolinux.com/
</VirtualHost>