Use .htaccess to resolve Prestashop error page issue after you enable “Friendly Url”

The “Friend URL” option in Prestashop sets the Prestashop to display all pages with a readable link. Usually, it works automatically when the option is turned on. However, I recently encountered the error page after I enabled the “Friendly URL” option.

After carefully investigation, the Prestashop error page was caused by the apache rewrite setting.

Firstly, Prestashop generated the .htaccess file when the “Friendly URL” option is enabled. However, if the apache rewrite is not set properly, the “Friendly URL” will not work.

Sudo vim /etc/apache2/sites-available/mywebsite.conf

Add the following code

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.unicoq.com [OR]
RewriteCond %{SERVER_NAME} =unicoq.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

So the final conf file will look like this (make sure you change the domain name/link to yours).

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin info@unicoq.com
        ServerName www.unicoq.com
        ServerAlias unicoq.com
        Redirect permanent / https://unicoq.com.com/

        DocumentRoot /var/www/html/unicoq.com/public_html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.unicoq.com [OR]
RewriteCond %{SERVER_NAME} =unicoq.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>


Leave a Reply