通过apache的rewrite实现URL重定向

这一技术通过apache的rewrite可以实现,当然你得把不带www的域名指向你服务器的IP

要是虚拟主机的话,得在viralhost段加入 ServerAlias xxx.com

然后打开重写引擎功能

RewriteEngine On

能过rewritecond判断主机名是否带www

RewriteCond %{HTTP_HOST} ^xxx/.com$ [NC]

然后来一条

RewriteRule ^/(.*) http://www.xxx.com/1 [R=301,L]

OK,重起apache,现在在浏览器中输入 xxx.com 看看是不是自动变成了www.xxx.com了呢。

重新整理一下就是:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^xxx/.com$ [NC]

RewriteRule ^/(.*) http://www.xxx.com/1 [R=301,L]

相关推荐
SeaTunnel13 小时前
结项报告完整版 | Apache SeaTunnel支持metalake开发
apache
迦蓝叶18 小时前
Apache Jena 知识图谱持久化:选择适合你的存储方案
人工智能·开源·apache·知识图谱·持久化·存储·jena
q***98521 天前
【保姆级教程】apache-tomcat的安装配置教程
java·tomcat·apache
DolphinScheduler社区1 天前
Apache DolphinScheduler 新增 gRPC 任务插件 | 开源之夏成果总结
大数据·开源·apache·海豚调度
Monody_R1 天前
rhce作业
linux·服务器·apache
CodeBlossom1 天前
Apache POI
apache
数新网络1 天前
The Life of a Read/Write Query for Apache Iceberg Tables
人工智能·apache·知识图谱
AI分享猿2 天前
雷池 WAF 免费版实测:企业用 Apache 搭环境,护住跨境电商平台
web安全·github·apache
Chief_fly2 天前
RestTemplate 和 Apache HttpClient 实现 HTTP 请求
网络协议·http·apache
浔川python社2 天前
《Python 小程序编写系列》(第三部):简易文件批量重命名工具
python·小程序·apache