Link to home
Start Free TrialLog in
Avatar of tonyhhisc
tonyhhisc

asked on

Need help with 301 Redirect w/.htaccess

I was able to get this working on most of my web sites. However, I'm having trouble with this one. It has some other scripting which I have no idea what it is and I'm sure it's conflicting with what I'm trying to add. I need my existing code to still function which handles friendly url's, but still want to add new code to do the 301 redirect.

When adding in the couple lines that I added on my other sites it produces an error when testing the redirect at domain.com (without www):

Moved Permanently

The document has moved here.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at domain.com Port 80


Here is the Current .htaccess file on the site:

<IfModule mod_rewrite.c>

Options -Indexes

RewriteEngine On
RewriteBase /


RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^_assets.
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|print-image\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php

</IfModule>

Open in new window



I was trying to add:

rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 

Open in new window


But when I do it gives me the "Moved Permanently" page.

Thanks for your help or suggestions!
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonyhhisc
tonyhhisc

ASKER

Thanks ! I added it lower down in the file and all seems to be working now. Thank you!