Welcome to WebmasterWorld Guest from 54.145.235.72

Forum Moderators: Ocean10000 & incrediBILL & phranque

non-www to www 301 redirect

301 redirect returns internal server error

   
12:12 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



I have 2 websites that share the same server. I use the below code for non-www to www 301 redirect. One of the websites is working perfectly while the other is returning an internal server error when I try to visit the website. I have the code placed in each sites respective folder that contains that sites index file. I have chmod permissions set to 0664 for both sites.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

Would anyone have any idea as to what I am doing incorrectly?

Kind regards and thanks in advance for any help,
yeto
12:16 pm on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Try this in each site.

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


Try it without the Options line too.
1:12 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



Thank you for your quick reply. I tried the new script but I am still having the same problem. One site works as expected. The other site returns the following error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Thank you,
yeto
1:18 pm on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



So, what does it say in the server error log?

That's server error log, not access log.
2:19 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



Listed below are parts, of some of the lines, of the error log.

.htaccess: Expected </html>RewriteEngine> but saw </html>

.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://www.example.com/


Thanks for trying to help,
yeto
2:23 pm on Jun 29, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Why have you got HTML tags in your htaccess file?
3:12 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



hmmmmmmm--I don't. Maybe somehow the file manager is adding them in. I will check that.

Thanks,
yeto
3:22 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



Okay--the file manager/file editor was in html mode. I clicked and changed it to text mode and entered the script. I am now getting a different message when I try to visit the web page.

The website declined to show this webpage
HTTP 403
Most likely causes:
•This website requires you to log in.
What you can try:
Go back to the previous page.
More information

Thanks for your help,
yeto
3:24 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



from log file:

htdocs/example/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
3:31 pm on Jun 29, 2012 (gmt 0)

5+ Year Member



I went back in and changed the permissions from 640 to 644 and now everything is working. I cannot tell you enough how grateful I am for your help. Could I please ask what is the difference between chmod 640 and 644 and is it okay to use 644?

Kind regards,
yeto
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month