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/ 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 !mod_rewrite.c>
ErrorDocument 404 /index.php


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!
Web Languages and StandardsWeb Development

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks ! I added it lower down in the file and all seems to be working now. Thank you!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy