Jump to content

[Solved] When friendly URLs are enabled, my site breaks


festival

Recommended Posts

I've read around the forums quite a bit about the issue, and I know mod rewrite is enabled on my server, and I've generated an .htaccess file... but something is still wrong.

All of the product images will be missing and when I view the product, it says the page cannot be found.

My .htaccess file looks like this:

# Catch 404 errors
ErrorDocument 404 /404.php



Which seems oddly short...

Link to comment
Share on other sites

That file is missing all the friendly URL code. It has the 404 redirect code only. Try going to the Preferences tab and making sure that "Friendly URL" is "Yes", then go to Tools > Generators and click "Generate .htaccess file". You should get a file similar to the following:

# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums

# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /img/p/$1-$2$3.jpg [L,E]
RewriteRule ^([0-9]+)\-([0-9]+)/([_a-zA-Z0-9-]*)\.jpg$ /img/p/$1-$2.jpg [L,E]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /img/c/$1$2.jpg [L,E]
RewriteRule ^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /product.php?id_product=$3&isolang;=$1$5 [L,E]
RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /product.php?id_product=$2&isolang;=$1$4 [L,E]
RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /category.php?id_category=$2&isolang;=$1 [QSA,L,E]
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]
RewriteRule ^lang-([a-z]{2})/(.*)$ /$2?isolang=$1 [QSA,L,E]

# Catch 404 errors
ErrorDocument 404 /404.php

Link to comment
Share on other sites

Am I being incredibly thick about this? In my I go prestashop tools generate and I see:
Warning: this tool can ONLY be used if you are hosted by an Apache web server. Please ask your webhost.

This tool will automatically generate a ".htaccess" file that will grant you the possibility to do URL rewriting and to catch 404 errors.

If you do not have the "Friendly URL" enabled when generating the ".htaccess" file, such feature won't be available.

Before being able to use this tool, you need to:

- create a .htaccess blank file in dir: /
- give it write permissions (CHMOD 666 on Unix system)

In the demo of prestashop I see:

Warning: this tool can ONLY be used if you are hosted by an Apache web server. Please ask your webhost.

This tool will automatically generate a ".htaccess" file that will grant you the possibility to do URL rewriting and to catch 404 errors.

If you do not have the "Friendly URL" enabled when generating the ".htaccess" file, such feature won't be available.

Generate your ".htaccess" file by clicking on the following button:

This will erase your old .htaccess file!

(ie with a button to generate the htaccess file). Where am I going wrong? Thanks.

Link to comment
Share on other sites

Hello.

What about redirect from non www to www urls?
Is it enough to add:

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



... to existing prestashop htaccess generated file?
Friendly url's are ON
RewriteEngine ON

and in httpd.conf file uncommented:

LoadModule rewrite_module modules/mod_rewrite.so



Or is there another (better) way?

Thanks, W.

Link to comment
Share on other sites

  • 1 month later...

Hello,

I have a simillar problem. Whenever I enable the Friendly URL and generate the .htaccess file from the Back Office, the friendly url works in my website, but bugs the Back Office. I cannot access the Back Office when the Rewrite Engine is on. As long as I turn the Rewrite Engine OFF in the htaccess file, and the Friendly URL enabled – the website gives me the following error:

‘ Error We’re sorry, but the Web address you entered is no longer available ‘

I am using prestashop 1.3.1

How to make both the website and the BO work when htaccess is ON and Friendly URL enabled?

Can someone help me out? Thanks in advance.

Regards.

Link to comment
Share on other sites

  • 6 months later...
  • 3 weeks later...

When i set Friendly urls on in theback-office then my front-office isnt working correctly.
The customer login doesnt work any more.
What could it be? I have the .htaccess genererated by prestashop and added.

# URL rewriting module activation

RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule .* - [F]
RewriteBase /
Options +FollowSymLinks

# 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

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