I have been bequeathed a WordPress site that has been created in a sub-directory of our current main web site (standard HTML). So I have:
http://www.company.com/ as main site
and
http://www.company.com/newsite/ as the wordpress site.
The underlying directory structures are:
/company-com/
and
/company-com/newsite/
This is (needless to say) somewhat inconvenient. However it would be a problem for various reasons to change this structure so I would like to stick with if at all possible.
I have created a .htaccess file in the /company-com/ directory with (for example)
redirect permanent /aboutus.htm http://www.company.com/newsite/aboutus/
So far I have about 20 redirects for various pages.
This appeared to be working OK until I noticed by chance that we were getting 500 errors. This transpired to be intermittent. Calling our hosting provider 1and1, support said it was because we were running out of processing power and needed to upgrade our package (!). Previously I had raised an online ticket and got fed up of waiting for response. This ticket has replied saying problem is with .htaccess file.
Question:
Which one is correct? From what I have read the .htaccess file would cause permanent problems rather than intermittent so I would go with the lack of processing power.
Regards
Steve Booth
You have two separate issues here. The first is the constraints of the 1and1 hosting package. I assume that you are using their shared hosting package. This will the CPU that any individual script execution uses. My host has an “
RLimitCPU 15
” which means that no script can take more than 15 secs CPU. It may be that your applications are “bumping against” this limit and are timing out. I use a standard timing loop around all of my scripts where I add this to the start of my scripts:and this to the end of each script
where pageTimer() is:
where
debugMsg()
just does aerror_log( $msg . "n", 3, $debugFile );
and I regularly check script run-times by page. Doing this lets you know if something is taking too long. The second thing that you should do is to set your error log to a private file in your directory and collect all errors, then check this regularly.The second issue is your redirects. This should not cause this intermittent problem.
I have witnessed multiple occasions of sporadic 404 and 500 errors associated with redirects through .htaccess RewriteRules. The vast majority could be cured by adding a RewriteBase directive matching the base folder of your rewrites, e.g.:
or
In fact, many CMS systems already have such a RewriteBase directive in their pre-written .htacces files, which is commented out and only needs to be activated (e.g. Drupal, Joomla, TYPO3).
While this solved the problem for me in many cases, it still eludes me why this intermittend redirect errors happen at all. After all they should either happen or not happen, but not come and go randomly.