开发者

htaccess for www-only redirection

开发者 https://www.devze.com 2022-12-14 20:38 出处:网络
Is there any way I can redirect my urls to only use http://www.domain.com instead of http://domain.com?

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 开发者_如何学Cwww, does not work though
RewriteRule ^(.*)$ http://www.thehotelinventory.com/$1 [R=301,L] 

AddHandler php5-script .php


If you need to redirect from non-www to www, then redirect to HTTPS for certificates like THAWTE that dont support www non-www on SSL 123.

RewriteEngine On
#non-www to www
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

#Redirect to HTTPS before www redirect
RewriteEngine on
RewriteCond %{HTTPS}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Thanks to Brasil na Web Dev. Guys.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消