0

I need help. My store is running on Magento CE 1.9 and I wanted either add trailing slash to all my urls in Magento, or to get rid of it. Adding trailing slash didn't work, because some images and other linked files didn't want to load, so I added this in my .htaccess file, to get rid of trailing slash:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L,NE]

The slash disappeared, and the website was rendering correctly. However, now I noticed that reviews of my products don't get registered at all. The customer can click on the link to write a review, however, after clicking submit button the page refreshes, but there is no message that the reviews is successfully submitted. The reviews also doesn't get registered in the admin panel. Maybe some other modules don't work as well, but I still didn't notice.

This is how the link looks without the code above: http://xxxxxxx.com/review/product/list/id/1/category/3#review-form

And this is how the link looks with the code above: http://xxxxxxx.com/review/product/list/id/1/category/3#review-form

2 Answers2

1

Hope this work,

try this rule instead

RewriteCond %{REQUEST_URI}  !\.(php|phtml|html?|ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf|otf|woff|ttf|eot|xml|GIF|sql)$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]

This will add trailing slash to all url if the condition is meet.

Note : this will redirect the ajax url in onepage checkout also, so if you are using SSL in onepage checkout, add slash manually to all request url, or else this will cause error

Pendi Zhu
  • 26
  • 3
  • Thank you Pendi, I tried your solution and it works. First I encountered redirection loop for categories, but then I went to system/confguration/catalog/Search Engine Optimizations and I added "/" as Category URL Suffix. – Ivan Paunovic Mar 02 '15 at 09:08
  • Pendi, just one quick question please! After adding your code to .htaccess google webmaster tools couldn't fetch my robots.txt. I added |txt| in the code, and not webmaster tools managed to fetch it. Did I do the right thing? – Ivan Paunovic Mar 02 '15 at 10:22
  • Hi Ivan, yes, just add the exception to the list for files that you don't want to add the trailing slash – Pendi Zhu Mar 03 '15 at 02:30
  • will look like this RewriteCond %{REQUEST_URI} !\.(php|phtml|html?|ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf|otf|woff|ttf|eot|xml|GIF|sql|txt)$ – Pendi Zhu Mar 03 '15 at 02:38
0

go to your frontend//default/template/review/form.phtml file and add <?php echo $this->getBlockHtml('formkey'); ?> just after the <form> tag if it is not present there

Chamal Chamikara
  • 496
  • 6
  • 17
  • Chamal, I tried Pendi's solution first and it worked, so I didn't have a chance to try yours. However I'm sure it will help someone. – Ivan Paunovic Mar 02 '15 at 09:10