强制WWW与httpd.conf文件,而不是的.htaccess [英] Forcing WWW with httpd.conf rather than .htaccess

查看:111
本文介绍了强制WWW与httpd.conf文件,而不是的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在许多部队WWW读了起来。使用htaccess的把戏。 (如下图)

I've read up on many Force WWW. tricks using htaccess. (As Below)

Rewritecond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domina.com/$1 [R=301,L]

我不知道是否有一种方法在整个网站中使用httpd.config强制WWW。

I'm wondering if there is a method to force WWW using httpd.config across the entire site.

htaccess的作品一种享受,但我有很多子目录,其中大部分包含有自己的.htacess文件,它打破了WWW力在特定的子目录。

The htaccess works a treat, but I have many subdirectories, most of them include there own .htacess files, which breaks the force www in that particular subdirectory.

所以,我在想,有没有办法迫使这个WWW。进入httpd.config,跨不进行编辑的.htaccess整个网站?

So I was thinking, is there a way to force this "www." into httpd.config, across the entire site without editing .htaccess?

感谢。

推荐答案

这应该做到这一点:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

和维护HTTPS过:

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

这篇关于强制WWW与httpd.conf文件,而不是的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆