andymontgomery Posted March 17, 2010 Share Posted March 17, 2010 Can someone please tell me what should be in an .htaccess file. I wish to use friendly URLs. I'm running my site on a Linux host and have just completed my installation. So, do I just open notepad...save the file as .htaccess and ftp it to my root directory?I initially logged into the back of the shop and switched on friendly urls but noticed a lot of broken images and links from the home page. Did a lot of searching around for a solution but there are fragmented pieces of the contents of the file on various posts.Any help much appreciated.Andy Link to comment Share on other sites More sharing options...
heronfisher Posted March 18, 2010 Share Posted March 18, 2010 There are several things that developers, site owners and webmasters can do by using .htaccess file. Let’s look at some of them: * Prevent directory browsing * Redirect visitors from one page or directory to another * Password protection for directories * Change the default index page of a directory * Prevent hot-linking of images from your websiteSince .htaccess file allows us to make changes on a per-directory basis, the following are valid places to put the .htaccess file in: /.htaccess [placing in root folder of the site]/content/.htaccess [placing in content folder]/content/html/images/.htaccess [in the images folder] Link to comment Share on other sites More sharing options...
andymontgomery Posted March 18, 2010 Author Share Posted March 18, 2010 thanks for your reply but it doesn't really answer my question - what should be in the file? Link to comment Share on other sites More sharing options...
andymontgomery Posted March 23, 2010 Author Share Posted March 23, 2010 Ah! Just found it...For anybody who hasn't - Inside Prestashop - Tools / Generators - you'll see the generator for .htaccess. Link to comment Share on other sites More sharing options...
howard Posted May 14, 2010 Share Posted May 14, 2010 Ah! Just found it...For anybody who hasn't - Inside Prestashop - Tools / Generators - you'll see the generator for .htaccess. i haven't got the file generators in tools :question: Link to comment Share on other sites More sharing options...
rocky Posted May 14, 2010 Share Posted May 14, 2010 What version of PrestaShop are you using? Link to comment Share on other sites More sharing options...
howard Posted May 15, 2010 Share Posted May 15, 2010 hi Rocky it's 1_1_0_4 at the moment and I am hoping to upgrade to 2_5 as i have lost my BO stats for visits and visitors and visitors on line Link to comment Share on other sites More sharing options...
rocky Posted May 15, 2010 Share Posted May 15, 2010 That's why you don't have the Tools > Generators option. It was added in PrestaShop v1.2.5. In PrestaShop v1.1, you have to rename htaccess.txt to .htaccess and manually change the paths. Link to comment Share on other sites More sharing options...
mowax Posted September 30, 2010 Share Posted September 30, 2010 Hi Rocky,I am using prestashop 1.1, and am having difficulties with this. I have changed htaccess.txt to .htaccess, but then I don't know what to do. I managed to do this a while ago but this time it is proving more difficult. Could you tell me how you manually change the paths, as you mentioned?Thanks! Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 Take this line of the .htaccess file as an example: RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /product.php?id_product=$1$3 [L,E] By default, it expects PrestaShop to be installed in the root directory. If, for example, you have installed PrestaShop in the shop directory, you will need to change it to: RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /shop/product.php?id_product=$1$3 [L,E] Link to comment Share on other sites More sharing options...
mowax Posted October 3, 2010 Share Posted October 3, 2010 Hi, I haven't intentionally installed prestashop in a subdomain, so I don't think thats the problem. It is currently on a temporary url while I set up prestashop on a new hosting package: http://69.89.31.232/~duratexc/Should I wait until I've pointed the nameservers to the new hosting company before doing this?My .htaccess file is below, in case anyone can spot something wrong with it:# URL rewriting module activationRewriteEngine onRewriteBase /# URL rewriting rulesRewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$2$4 [L,E]RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$1$3 [L,E]RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ category.php?id_category=$1 [QSA,L,E]RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ cms.php?id_cms=$1 [QSA,L,E]RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ supplier.php?id_supplier=$1$3 [QSA,L,E]RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]# Catch 404 errorsErrorDocument 404 /404.phpI also tried adding the following code that my hosting company gave me, but it had no effect:RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]All I get are 404 not found errors, I am at a loss here. Please help! Link to comment Share on other sites More sharing options...
rocky Posted October 3, 2010 Share Posted October 3, 2010 Until you've got your domain name set up, you will need to change your "PS directory" on the Preferences tab to /~duratexc/ then change your .htaccess file to: # URL rewriting module activation RewriteEngine on RewriteBase / # URL rewriting rules RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /~duratexc/product.php?id_product=$2$4 [L,E] RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /~duratexc/product.php?id_product=$1$3 [L,E] RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /~duratexc/category.php?id_category=$1 [QSA,L,E] RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /~duratexc/cms.php?id_cms=$1 [QSA,L,E] RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ /~duratexc/supplier.php?id_supplier=$1$3 [QSA,L,E] RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ /~duratexc/manufacturer.php?id_manufacturer=$1$3 [QSA,L,E] # Catch 404 errors ErrorDocument 404 /404.php Once you've got your domain name working, you will need to change the "PS directory" to / then remove /~duratexc from the above code, leaving just a / Link to comment Share on other sites More sharing options...
mowax Posted October 4, 2010 Share Posted October 4, 2010 That was the ticket! Works perfectly, thanks so much Rocky. I'm your latest facebook fan Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now