htaccess的为WWW-仅重定向重定向、htaccess、WWW

2023-09-02 00:30:57 作者:晨光°

有什么办法我也可以把我的网址,只使用 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

htaccess隐藏index.php,301重定向等等..

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