Forum Moderators: phranque
I have the following structure in my ftp setup: / -- home -- mysitename -- www -- subdirectories.
OK, now I'm really confused. I am on a shared server. In directory / are all kinds of files I don't mess with like bash_history, bin, boot, etc. In directory "home" are everybody's sitenamed folders, including mine. In mysitename directory are more files I don't mess with, bash_history, .pinerc, .redirect (I have to look at that one), etc. plus my www folder. I now have .htaccess file in both the mysitename and www directories. Somebody please help me out here?
I am assuming that the www is what most of you are calling "root". Please correct me if I'm wrong.
Below is the code I'm using on a Unix server, which I believe is Apache.
-------------
Options +FollowSymLinks
AllowOverride FileInfo
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) [example.com...] [R=301,L]
------------
The code you posted should work for internal directories also, as long as the code is in the 'root' (main) directory .htaccess.
Have you tested the version posted? (I'm guessing you have, but it doesn't hurt to ask.)
Are you sure your browsers cache was emptied when you tested? (I've forgotten this on a large number of occasions.)
Are you using any .htaccess files in specific directories that are not redirecting? (If this is the case, try adding the lines of code you posted to the top of the .htaccess file in the specific directory.)
Justin
Yep it's in the root directory.
"Have you tested the version posted? (I'm guessing you have, but it doesn't hurt to ask.)"
Well, blush, I actually hadn't. I'd read somewhere on one of these forums someone stating that they'd done this 301 redirect from domain.com to www.domain.com and they'd stated they done this for their sub-dirs as well. So I'd assumed there was another command to put in my .htaccess file (but presumably they meant they'd put something similar in the sub-dirs .htaccess file).
I just tested it, and the sub-dirs seem to be resolving to www.domain.com. So all seems to be well.
"Are you sure your browsers cache was emptied when you tested? (I've forgotten this on a large number of occasions.)"
Me too :( I usually remember when I double/triple checked my syntax etc, make sure I've uploaded the .htaccess file at least 3 times, scratching my head... this *should* be working.. then... click... lightbulb goes on... clear cache... everything working :)
"Are you using any .htaccess files in specific directories that are not redirecting? (If this is the case, try adding the lines of code you posted to the top of the .htaccess file in the specific directory.)"
Nope. Just in the root directory. Thanks for your help.
Have tried it two ways (have never ever managed to get this working):-
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.mydomain\.org [NC]
RewriteRule (.*) http://www.mydomain.org/$1 [R=301,L]
and
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.org
RewriteRule ^(.*) http://www.mydomain.org/$1 [L,R=301]
I have also tried pretty much all of the examples in the rest of this thread.
Is there a possibility that we have a configuration problem somewhere?
Thanks,
TJ
[edited by: jdMorgan at 7:57 pm (utc) on July 11, 2005]
[edit reason] Unlinked. [/edit]
You may need to enable mod_rewrite by adding
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
Or you may indeed have a server config problem; The error log will usually tell you what's wrong.
Jim
[webmasterworld.com...]
...as this thread seemed to die on me ;-)
Thanks,
TJ
Chuck