Jump to content

htaccess edit causing slow performance


Recommended Posts

My shop doesn't redirect from http:// domainname.com to http:// www.domainname.com and I've checked all my settings are correct. In another post someone recommended making the following edit to the htaccess file, which I added right at the top (so it's not overwritten). I took out the command "RewriteEngine On" since this already appears below. I can confirm that this does enable the redirection to work correctly.

 

RewriteCond %{HTTP_HOST} ^domainname.com$
RewriteRule (.*)$ http://www.domainname.com/$1 [R=301,L]

 

 

However, (this is related to another post I've just made about performance) in addition to the cache setting, I've found this edit to the htaccess file causes intermittent performance issues (so bad that the site practically crashes). I can only guess that some kind of loop/conflict is being created with the existing htaccess content that is generated automatically (although I'm not really sure).

 

Can anyone help me enable this redirect functionality so that it doesn't cause such performance issues?

Edited by Andrew H (see edit history)
Link to comment
Share on other sites

you redirect doesn't work (I think) because if it's www, it will not match and then not redirect, well amongst other problems with your code...that is the most obvious. Try this:

<IfModule mod_rewrite.c>
RewriteEngine On
	RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
	RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
</IfModule>

 

note this will not account for non www. though that is easy enough to add

Link to comment
Share on other sites

Thanks for your response. This is how I implemented the code, at the top, above the automatically generated code... The below works, but causes performance issues. Could you tell me how to modify your version to cover redirecting non-www to www

 

RewriteCond %{HTTP_HOST} ^domainname.com$
RewriteRule (.*)$ http://www.domainname.com/$1 [R=301,L]
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domainname.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

Link to comment
Share on other sites

I don't know why it would cause performance issues. Just saying it causes performance issues does not necessarily mean that is the issue.

 

so it's working...can you describe why you think this is related to a performance issue? also this would be better asked or researched outside of prestashop, i.e. based on your OS

  • Like 1
Link to comment
Share on other sites

I might have been wrong about it causing performance issues, but I moved your suggested code under the automated htaccess content and don't seem to have had too many more problems. However, I noticed I have a 30MB with 517,000 rows ps_guest table which I'm thinking might actually be my cause of slow performance. Thanks again for your help. I've been advised in a different post that this table is safe to delete (my overall database is only about 80MB so 30MB on ps_guest seems a bit excessive). Here is my other post: http://www.prestasho...81#entry1329881

Edited by Andrew H (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...