Forum Moderators: phranque
First, I must admit that I don't have any previous experience with the *nix file system.
I have more than one domain name in my hosting account, and when I added the additional ones I didn't know where to point them. So what I did was put them in folders like: /var/www/domainname/
I couldn't get mod_rewrite to work, so I changed them from the /var/www/domainname/ directories to /var/www/html/domainname/ directories. I guess .htaccess only works when it's at or below the html directory, because now the .htaccess file is having some effect.
I'm trying to just get the example that one of the administrators of this board posted a while back (setting up a rewrite so that page1.html would redirect to page2.html). It works fine when I type in www.mydomainname.com/page1.html, sending me to [mydomainname.com...] However, when I type this in it hacks off the www. before mydomainname.com/page2.html. Then, when I change page2.html to page1.html to replicate the redirect, it goes to: mydomainname.com/var/www/html/mydomainname/page2.html. It throws up an error page when this happens.
I've tried dozens of variations in the .htaccess file, but they all hack off the www. off and then don't work at all subsequently.
My current .htaccess file is:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^page1\.html$ page2.html [R=301,L]
Any help would be appreciated.
As to hacking off the "www", I'd suggest you use UseCanonicalName off in your httpd.conf, as it will force access to the specified server name to construct canonical URLs (see Apache core docs).
That's prrety much all I know on this subject. Hopefully, you'll get some better help.
Jim