Reputation: 5067
Prestashop 1.7.2.4
After installation, the first lines of the generated .htaccess contains the following content:
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_rewrite.c> ... ..
When I install one of the modules, it adds its own rewrite rules at the end of the .htaccess. This is done using PHP file functions (file_put_contents
, file_get_contents
) but with an append option. Unfortunately, this don't work until you put the rules on the top of the .htaccess file ( to precede some other rules that concern the same pattern). So I changed the behavior of module to prepend instead of appending.
The problem: I don't understand the comments by PS at the beginning of .htaccess. Does it mean module rules should necessarily be appended at the end(like module authors did)?
Upvotes: 1
Views: 2151
Reputation: 18950
There is a lot of confusion we face since PrestaShop 1.5 whether a customized .htaccess file gets overwritten by PrestaShop during .htaccess generation or not.
In fact, PrestaShop will not overwrite changes in the .htaccess
file if they custom rules are put in the correct places: Before or after the automatically generated rule mappings!
Example: .htaccess
Your custom rules
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
...
... auto-generated rules
...
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
Your custom rules
PS: Changing core functionality sounds pretty bad.
Upvotes: 1