htaccess的为WWW-仅重定向 [英] htaccess for www-only redirection

查看:124
本文介绍了htaccess的为WWW-仅重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法我也可以把我的网址,只使用 http://www.domain.com 代替的 http://domain.com

下面是我的htaccess,但不工作:

 #打开URL重写
RewriteEngine叙述上

#安装目录
#的RewriteBase /测试/
选项​​+的FollowSymLinks

#被查看保护应用程序和系统文件
重写规则^(应用|模块|系统) -  [F,L]

#允许存在直接显示的任何文件或目录
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d

#重写所有其他URL的index.php / URL
重写规则。*的index.php / $ 0 PT,L]

#redirec

#detect网址加www
的RewriteCond%{HTTP_HOST} ^ thehotelinventory.com [NC]

#REDIRECT到www,没有工作,虽然
重写规则^(。*)$ http://www.thehotelinventory.com/$1 [R = 301,L]

AddHandler的PHP5脚本的.php
 

解决方案

一个简单的答案可以在这里找到:的 http://snippets.dzone.com/posts/show/2264

Is there any way I can redirect my urls to only use http://www.domain.com instead of http://domain.com?

Here's my htaccess but doesnt work:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
# RewriteBase /test/
Options +FollowSymlinks

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

#redirec

#detect urls without www
RewriteCond %{http_host} ^thehotelinventory.com [NC]

#redirect to www, does not work though
RewriteRule ^(.*)$ http://www.thehotelinventory.com/$1 [R=301,L] 

AddHandler php5-script .php

解决方案

a simple answer can be found here: http://snippets.dzone.com/posts/show/2264

这篇关于htaccess的为WWW-仅重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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