在 prestashop 1.7 .htaccess 中将重写规则放在哪里?
Where to put rewrite rules in prestashop 1.7 .htaccess?
Prestashop 1.7.2.4
安装后,生成的.htaccess第一行包含以下内容:
# ~~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> ... ..
当我安装其中一个模块时,它在 .htaccess 的末尾添加了自己的重写规则。这是使用 PHP 文件函数(file_put_contents
、file_get_contents
)完成的,但带有追加选项。不幸的是,除非您将规则放在 .htaccess 文件的顶部(以在涉及相同模式的其他一些规则之前),否则这不会起作用。所以我将模块的行为更改为前置而不是附加。
问题:我不明白 PS 在 .htaccess 开头的注释。这是否意味着模块规则必须附加在末尾(就像模块作者所做的那样)?
自 PrestaShop 1.5 以来,我们面临着很多困惑,无论自定义 .htaccess 文件是否在 .htaccess 生成期间被 PrestaShop 覆盖。
事实上,如果将自定义规则放在正确的位置,PrestaShop 将不会覆盖 .htaccess
文件中的更改:之前 或之后自动生成的规则映射!
示例:.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:更改核心功能听起来很糟糕。
Prestashop 1.7.2.4
安装后,生成的.htaccess第一行包含以下内容:
# ~~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> ... ..
当我安装其中一个模块时,它在 .htaccess 的末尾添加了自己的重写规则。这是使用 PHP 文件函数(file_put_contents
、file_get_contents
)完成的,但带有追加选项。不幸的是,除非您将规则放在 .htaccess 文件的顶部(以在涉及相同模式的其他一些规则之前),否则这不会起作用。所以我将模块的行为更改为前置而不是附加。
问题:我不明白 PS 在 .htaccess 开头的注释。这是否意味着模块规则必须附加在末尾(就像模块作者所做的那样)?
自 PrestaShop 1.5 以来,我们面临着很多困惑,无论自定义 .htaccess 文件是否在 .htaccess 生成期间被 PrestaShop 覆盖。
事实上,如果将自定义规则放在正确的位置,PrestaShop 将不会覆盖 .htaccess
文件中的更改:之前 或之后自动生成的规则映射!
示例:.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:更改核心功能听起来很糟糕。