Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com$ [NC]
rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301]
also tried
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
Site background
I have a landing page at www.example.com (in the public_html root) with an enter link to the main site which is an oscommerce site in a folder "catalog" also in public_html folder
Both versions of the redirect work as expected in Firefox, however in Internet Explorer the redirect works but none of my CSS menues or site graphics show up just text.
Anyone have a clue what IE is doing different from Firefox or a way to solve the issue?
Any help is greatly appreciated!
[edited by: tedster at 4:12 am (utc) on Jan. 31, 2009]
[edit reason] switch to example.com - it can never be owned [/edit]
If not, either browser may serve you stale, outdated pages or server responses until the cache entries expire or are replaced by newer ones.
As a side question, do you use additional domains or subdomains other than "www" on this site? The rules you posted above will redirect non-www to www, but they won't redirect "junk.example.com" to www. Neither will they redirect any www or non-www requests if there is an appended port number of FQDN token -- both of which are legal and can happen.
Jim
[edited by: jdMorgan at 8:27 pm (utc) on Jan. 31, 2009]
There are no additional domains only the 1.
Also retried the syntax of RewriteCondition vs what I had as rewritecondition same issue.
As soon as I replace .htaccess with the original(exactly the same but without the redirect) everthing returns to normal and works correctly.
I think the fact that the pics and CSS are not working in IE may be some type of good clue(I can't figure it out though) we use a CSS for the main page located in the /public_html and another CSS for the oscommerce .php site located at /public_html/catalog, Firefox handles the redirect and everything else fine..
A little stumped here, this should work in IE?
again here is what I have tried to date.
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com$ [NC]
rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301]
also tried
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
and
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Unfortunately, there isn't an MSIE browser add-on like "Live HTTP Headers" for Firefox, so you can't check the HTTP request headers that MSIE is with its requests for the included image and CSS files, etc. that don't seem to be working. So, all I can recommend is to look at *both* your server access log and your server error log, and see if you can spot some difference in what each browser is requesting.
We see this kind of problem with *all* browsers when people are using page-relative links to included objects and then install internal rewrites which change the effective "directory-level" of their URLs. But the cause of this problem does not exist when an external redirect is used, and you're only seeing it with one browser. So this is a really strange problem.
You might want to carefully review the rest of your .htaccess file(s) and make sure there are no other directives involved with image and CSS delivery which also have HTTP_HOST dependencies.
Jim
Heres what did the trick, not quite sure why this syntax worked and the others didn't maybe someone could shed some light, I'm of the "you cangive a man a fish and he'll eat for a day" "you can teach a man to fish and he'll eat for a lifetime" frame of mind and would like to understand this.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^mysite.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) [mysite.com...] [L,R]
Previous tries for comp.
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com$ [NC]
rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301]
>>>>>>>>>>>
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
>>>>>>>>>>
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
In fact, fix the leading slash problem and the code will generate an infinite loop due to the other problem, unless you change the condition to "not www.mysite" instead.
You're still using random capitalisation of the reserved words in your rules. That always makes me uneasy.
## REDIRECT NON-WWW TO WWW
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R=301,L]
Ray...
# $Id: .htaccess 1739 2007-12-20 00:52:16Z hpdl $
#
# This is used with Apache WebServers
#
# For this to work, you must include the parameter 'Options' to
# the AllowOverride configuration
#
# Example:
#
# <Directory "/usr/local/apache/htdocs">
# AllowOverride Options
# </Directory>
#
# 'All' with also work. (This configuration is in the
# apache/conf/httpd.conf file)
# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers
#<IfModule mod_setenvif.c>
# <IfDefine SSL>
# SetEnvIf User-Agent ".*MSIE.*" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
# </IfDefine>
#</IfModule>
# If Search Engine Friendly URLs do not work, try enabling the
# following Apache configuration parameter
# AcceptPathInfo On
# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)
# php_value session.use_trans_sid 0
# php_value register_globals 1
You should enable that "downgrade" code for MSIE that is commented-out above, though. I'm not sure if it will affect this problem or not. But because this is an external redirect, I strongly feel that this is a client-side problem, and not a server-side problem.
Jim
In case any poor unfortunate person runs into this issue with 301 redirects working with oscommerce here is the fix.
I used waiders sample redirect
Options+FollowSymlinks
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R=301,L]
although I have now tried it with many of the first ones I used and all are OK.
The key is to mod 2 files in oscommerce
#1 very important if you want to be able to access your admin section once the redirect is in place(so do this first!)
catalog/admin/includes/configure.php
Make sure the first 3 lines include the www(by default oscommerce only uses [mysite.com...] for both the admin and catalog configure.php)
define('HTTP_SERVER', 'http://www.mysite.com');
define('HTTP_CATALOG_SERVER', 'http://www.mysite.com');
define('HTTPS_CATALOG_SERVER', 'http://www.mysite.com');
Then in catalog/admin/includes/configure.php
Same thing make sure the first 2 lines include the www.
define('HTTP_SERVER', 'http://www.mysite.com');
define('HTTPS_SERVER', 'http://www.mysite.com');
Thats it and everything will function as it should!
Thanks again for all your help, this is an awesome forum!
I'd strongly suggest:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
See further explanatory comments in this concurrent thread: [webmasterworld.com...]
Jim
[edited by: jdMorgan at 3:29 am (utc) on Feb. 2, 2009]