Forum Moderators: phranque
RewriteEngine On
RewriteBase /# You could need to un-comment the following line, gives 500 server error
# Options +FollowSymlinks# Redirect from http://example.com to http://www.example.com
# RewriteCond %{HTTP_HOST} !^www\.example\.com
# RewriteRule (.*) http://www.example.com/$1 [R=301,L]# rewritecond %{http_host} ^example.com [nc]
# rewriterule ^(.*)$ http://www.example.com/$1 [r=permanent,nc]# This one did a 301 from http://www.example.com to http://example.com properly
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^example\.com
# RewriteRule (.*) http://example.com/$1 [R=301,L]# RewriteCond %{HTTP_HOST} ^example.com [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]# rewritecond %{http_host} ^example.com [nc]
# rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]# RewriteCond %{HTTP_HOST} ^example.com
# RewriteRule (.*) http://www.example.com/$1 [R=301,L]# Don't even know where to put this... in the header file? Didn't do anything...
# <?php
# if(!stristr($_SERVER["HTTP_HOST"], 'www')){
# header("HTTP/1.1 301 Moved Permanently");
# header("Location: http://www.example.com/" . $_SERVER["REQUEST_URI"]);
# exit();
# }
#?># Statements Not Supported By Host
# Action
# AddCharSet
# AddEncoding
# AddLanguage
# AddType
# BrowserMatch
# BrowserMatchNoCase
# CookieTracking
# DefaultLanguage
# DefaultType
# ErrorDocument
# ErrorHeader
# Header
# LanguagePriority
# Options
# PassEnv
# Redirect
# RedirectMatch
# RedirectPermanent
# RedirectTemporary
# SetEnv
# SetEnvIf
# SetEnvIfNoCase
# UnsetEnv
Any help is greatly appreciated.
[edited by: jdMorgan at 11:23 pm (utc) on Aug. 19, 2007]
[edit reason] example.com [/edit]
Begging your pardon for being forthright, but you need a new host, as this one appears to be both too restrictive and --based on their given reason for not allowing mod_alias-- incompetent.
If you want to modify your server configuration with .htaccess, consider spending the $14.95 a month (this should be a maximum price for a single account) it takes to move up to a decent class of shared hosting -- It will be well worth it in your time-savings alone. Eschew hosting resellers and go straight to a provider that owns its own datacenters. Note that I don't have any particular prejudice against resellers, but if you have a problem, you'll want to be able to go straight to the people who own/administrate the hardware, and not have to deal with extra problems like a reseller who's out of the country on holiday for a month...
Considering the time spent on the problems it causes, cheap hosting is the most expensive hosting you can buy.
The code snippet you've included that starts with "<?php" is a PHP script. You should give it a filename and placed in a file anywhere within your Web-accessible space where scripts may be executed (i.e. where they can be given the required 'execute' permissions). When things are set up properly, you should then be able to run it by typing its URL.
Jim
The PHP code does redirect properly, but I need to include it in the header file, because every page that's http:// should go to www. with a 301. Doing that with that code just gives infinite loop if it's in the header because it keeps redirecting once it gets to it's destination. I'm not sure how to write a script to do this in PHP without causing it to loop.
I'm almost positive the host has it setup to go to www. with a 302 automatically, but they are like you said... incompetent, the customer service doesn't even know what I'm talking about it seems.