Jump to content

[SOLVED] Installing .htaccess


Recommended Posts

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

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 website

Since .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

  • 1 month later...
  • 4 months later...

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

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

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 activation
RewriteEngine on
RewriteBase /


# URL rewriting rules
RewriteRule ^([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 errors
ErrorDocument 404 /404.php



I also tried adding the following code that my hosting company gave me, but it had no effect:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /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

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

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...