2.14.9.9. Стандартныя .htaccess для PrestaShop

Прыклад змесціва стандартных .htaccess для PrestaShop (генеруецца аўтаматычна пры ўсталёўцы):

  • З каранёвага каталога сайта:
    1. # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
    2. # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
    3. # http://www.prestashop.com - http://www.prestashop.com/forums
    4.  
    5. <IfModule mod_rewrite.c>
    6. <IfModule mod_env.c>
    7. SetEnv HTTP_MOD_REWRITE On
    8. </IfModule>
    9.  
    10. RewriteEngine on
    11.  
    12.  
    13. #Domain: www.example.com
    14. RewriteRule . - [E=REWRITEBASE:/]
    15. RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
    16.  
    17. # Images
    18. RewriteCond %{HTTP_HOST} ^www.example.com$
    19. RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
    20. RewriteCond %{HTTP_HOST} ^www.example.com$
    21. RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
    22. RewriteCond %{HTTP_HOST} ^www.example.com$
    23. RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
    24. RewriteCond %{HTTP_HOST} ^www.example.com$
    25. RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
    26. RewriteCond %{HTTP_HOST} ^www.example.com$
    27. RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
    28. RewriteCond %{HTTP_HOST} ^www.example.com$
    29. RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
    30. RewriteCond %{HTTP_HOST} ^www.example.com$
    31. RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
    32. RewriteCond %{HTTP_HOST} ^www.example.com$
    33. RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
    34. RewriteCond %{HTTP_HOST} ^www.example.com$
    35. RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
    36. RewriteCond %{HTTP_HOST} ^www.example.com$
    37. RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
    38. # AlphaImageLoader for IE and fancybox
    39. RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
    40.  
    41. # Dispatcher
    42. RewriteCond %{REQUEST_FILENAME} -s [OR]
    43. RewriteCond %{REQUEST_FILENAME} -l [OR]
    44. RewriteCond %{REQUEST_FILENAME} -d
    45. RewriteRule ^.*$ - [NC,L]
    46. RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
    47. </IfModule>
    48.  
    49. AddType application/vnd.ms-fontobject .eot
    50. AddType font/ttf .ttf
    51. AddType font/otf .otf
    52. AddType application/font-woff .woff
    53. AddType font/woff2 .woff2
    54. <IfModule mod_headers.c>
    55. <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg)$">
    56. Header set Access-Control-Allow-Origin "*"
    57. </FilesMatch>
    58. </IfModule>
    59.  
    60. #If rewrite mod isn't enabled
    61. ErrorDocument 404 /index.php?controller=404
    62.  
    63. # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
  • З падкаталога адмін-панэлі (GitHub):
    1. # Use the front controller as index file. It serves as a fallback solution when
    2. # every other rewrite/redirect fails (e.g. in an aliased environment without
    3. # mod_rewrite). Additionally, this reduces the matching process for the
    4. # start page (path "/") because otherwise Apache will apply the rewriting rules
    5. # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
    6. DirectoryIndex index.php
    7.  
    8. # By default, Apache does not evaluate symbolic links if you did not enable this
    9. # feature in your server configuration. Uncomment the following line if you
    10. # install assets as symlinks or if you experience problems related to symlinks
    11. # when compiling LESS/Sass/CoffeScript assets.
    12. # Options FollowSymlinks
    13.  
    14. # Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
    15. # to the front controller "/app.php" but be rewritten to "/app.php/app".
    16. <IfModule mod_negotiation.c>
    17. Options -MultiViews
    18. </IfModule>
    19.  
    20. <IfModule mod_rewrite.c>
    21. RewriteEngine On
    22.  
    23. # Determine the RewriteBase automatically and set it as environment variable.
    24. # If you are using Apache aliases to do mass virtual hosting or installed the
    25. # project in a subdirectory, the base path will be prepended to allow proper
    26. # resolution of the app.php file and to redirect to the correct URI. It will
    27. # work in environments without path prefix as well, providing a safe, one-size
    28. # fits all solution. But as you do not need it in this case, you can comment
    29. # the following 2 lines to eliminate the overhead.
    30. RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    31. RewriteRule ^(.*) - [E=BASE:%1]
    32.  
    33. # Sets the HTTP_AUTHORIZATION header removed by apache
    34. RewriteCond %{HTTP:Authorization} .
    35. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    36.  
    37. # Keep legacy entry points
    38. RewriteRule ^(ajax|ajax_products_list|ajax-tab|backup|cron_currency_rates)\.php - [P]
    39. RewriteRule ^(displayImage|drawer|footer\.inc|functions|get-file-admin)\.php - [P]
    40. RewriteRule ^(grider|header\.inc|init|login|password|pdf|searchcron)\.php - [P]
    41.  
    42. # If the URL is a legacy on index.php?controller=., do not rewrite (let the legacy take it)
    43. RewriteCond %{QUERY_STRING} (^|&)controller=|(^|&)tab=
    44. RewriteRule .* - [P]
    45.  
    46. # Redirect to URI without front controller to prevent duplicate content
    47. # (with and without `/app.php`). Only do this redirect on the initial
    48. # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    49. # endless redirect loop (request -> rewrite to front controller ->
    50. # redirect -> request -> .).
    51. # So in case you get a "too many redirects" error or you always get redirected
    52. # to the start page because your Apache does not expose the REDIRECT_STATUS
    53. # environment variable, you have 2 choices:
    54. # - disable this feature by commenting the following 2 lines or
    55. # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    56. # following RewriteCond (best solution)
    57. # RewriteCond %{ENV:REDIRECT_STATUS} ^$
    58. # RewriteRule ^index\.php(/(.*)) %{ENV:BASE}/$2 [R=301,L]
    59.  
    60. # If the requested filename exists, simply serve it.
    61. # We only want to let Apache serve files and not directories.
    62. RewriteCond %{REQUEST_FILENAME} -f
    63. RewriteRule .? - [L]
    64.  
    65. # Rewrite all other queries to the front controller.
    66. RewriteRule .? %{ENV:BASE}/index.php [L]
    67. </IfModule>
    68.  
    69. <IfModule !mod_rewrite.c>
    70. <IfModule mod_alias.c>
    71. # When mod_rewrite is not available, we instruct a temporary redirect of
    72. # the start page to the front controller explicitly so that the website
    73. # and the generated links can still be used.
    74. RedirectMatch 302 ^/$ /index.php/
    75. # RedirectTemp cannot be used instead
    76. </IfModule>
    77. </IfModule>
Змест