.htaccess default of Prestashop

.htaccess default from PrestaShop

The .htaccess file is a configuration file used on Apache-based web servers. It is used to control and configure the behavior of a website.
 
The .htaccess file has multiple functions and allows you to customize a website’s configuration in a specific way. Some of its main functions are:
  1. Redirects: You can redirect URLs from one page to another, which is useful when you change your website structure or want to redirect from an old version to a new one.
  2. Directory protection: You can restrict access to certain directories by specifying username and password permissions.
  3. Error customization: You can customize the error pages displayed when an error occurs on your website, such as the 404 error.
  4. Cache control: You can configure your website’s cache to improve page load time and reduce server load.
Example of default .htaccess code for PrestaShop
The code shown below is the default .htaccess file generated during a new PrestaShop installation:

# Enable URL rewrite engine
RewriteEngine On
# Set base directory
RewriteBase /
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Prevent direct access to files
RewriteRule ^config/(.*)\.php$ - [R=404,L,NC]
# Block access to certain directories
RewriteRule ^(?:admin|bin|cache|classes|config|controllers|docs|localization|log|override|pdf|src|tests|tools|translations|upload|var)/ - [F,L]
# Redirect SEO-friendly URLs
RewriteRule ^(.*)\.html$ /index.php?controller=$1 [QSA,L]
# Redirect traffic to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Remember that this is an example of a default .htaccess file for a new PrestaShop installation. You can customize it according to your specific needs and requirements.

The .htaccess file mentioned refers to the default configuration of the .htaccess file in PrestaShop 1.7. This configuration is valid and applies to PrestaShop 1.7.x versions.

If you need help verifying which version of PrestaShop you are using, you can easily check it from the PrestaShop administration panel. Simply go to the "Advanced Parameters" section in the side menu and click on "Information". There you will find the "Store Information" section, which displays the PrestaShop version you are using.



For more information, you can contact us.
    • Related Articles

    • Information and uses of the .htaccess file

      1.- What is a .htaccess? The .htaccess (hypertext access) file is the default name for Apache’s directory-level configuration file. It is used to customize the configuration of directives and parameters defined in the main hosting configuration file. ...
    • How to modify the domain and/or folder associated with Prestashop

      When we modify the site of our PrestaShop installation, the store may stop working. This happens because, at the time of installing PrestaShop, the current path is stored. To modify the paths of our installation, we must manage the PrestaShop ...
    • How to protect folders using a .htaccess

      Through the file .htaccess you can protect any directory in your hosting account. 1.- How to create and where to place a .htaccess and .htpasswd file To create a .htaccess or .htpasswd file, open Notepad and enter the required code. Save the file as ...
    • How to reset/delete prestashop cache

      Cache is a feature used by PrestaShop to temporarily store data and resources, which significantly improves the loading speed of your online store. However, as you make changes to the site, such as modifying the design, products, or categories, it ...
    • What is and how to fix the ERR_TOO_MANY_REDIRECTS error

      It is likely that while browsing the internet or even on your own website, you may have encountered an ERR_TOO_MANY_REDIRECTS message indicating that there are too many redirects to complete the connection. The error usually looks like this: This ...