Where should be placed htaccess file in Prestashop 1.4x? - apache

my Prestashop 1.4x installed in a subdirectory, eg: http://mydomain.com/prestashop/
on Apache server.
There is option to generate Htaccess file from admins, which are copied into the /prestashop/ directory. Is it correct location or I should put htaccess into parent(root) directory?
example:
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# WARNING: PLEASE DO NOT MODIFY THIS FILE MANUALLY. IF NECESSARY, ADD YOUR SPECIFIC CONFIGURATION WITH THE HTACCESS GENERATOR IN BACK OFFICE
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on
# URL rewriting rules
RewriteRule ^([a-z]{2})/([0-9]+)\-[a-zA-Z0-9-]*\.html /store/product.php?id_product=$2&isolang=$1 [QSA,L]
... ... ...
... ... ...
RewriteRule ^en/best-sales$ /store/best-sales.php?isolang=en [QSA,L]
RewriteRule ^en/page-not-found$ /store/404.php?isolang=en [QSA,L]
</IfModule>
# Catch 404 errors
ErrorDocument 404 /store/404.php
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
FileETag INode MTime Size
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/css text/plain text/javascript application/javascript application/x-javascript
</IfModule>
</IfModule>

It is correct location for http://mydomain.com/store/

Related

'403 Forbidden error' when trying to access images on a Wordpress install

I have a dedicated server. I have installed wordpress in a subdirectory on it and uploaded some images via the 'media' option in the dashboard. But I am unable to access images directly (hotlinks) in the browser, however, I can see the images in the file manager (FTP) under /wp-content/uploads folder.
It is a fresh install with no plugins and only the default theme. I haven't done anything other than upload a few images via the media option. Please note that the error shows even when I click the 'library' option under the 'media' option in the dashboard.
I even tried creating a .user.ini file in both the directories with the exact same code as of php.ini as shown below, but that didn't help either. The hosting provider says they don't provide support for dedicated servers. What do I do now?
Here is the root directory .htaccess
<FilesMatch "\.(jpg|png|gif|js|css|ico)$">
<IfModule mod_headers.c>
Header set ETag ""
Header set Cache-Control "max-age=2592000"
Header set Expires "01 Jan 2112 00:00:00 GMT"
</IfModule>
</FilesMatch>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
<FilesMatch "\.(jpg|png|gif|js|css|ico)$">
<IfModule mod_headers.c>
Header set ETag ""
Header set Cache-Control "max-age=2592000"
Header set Expires "01 Jan 2112 00:00:00 GMT"
</IfModule>
</FilesMatch>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
# BEGIN SUGARCRM RESTRICTIONS
RedirectMatch 403 (?i).*\.log$
RedirectMatch 403 (?i)/+not_imported_.*\.txt
RedirectMatch 403 (?i)/+(soap|cache|xtemplate|data|examples|include|log4php|metadata|modules)/+.*\.(php|tpl)
RedirectMatch 403 (?i)/+emailmandelivery\.php
RedirectMatch 403 (?i)/+upload
RedirectMatch 403 (?i)/+custom/+blowfish
RedirectMatch 403 (?i)/+cache/+diagnostic
RedirectMatch 403 (?i)/+files\.md5$
# END SUGARCRM RESTRICTIONS
<FilesMatch "\.(jpg|png|gif|js|css|ico)$">
<IfModule mod_headers.c>
Header set ETag ""
Header set Cache-Control "max-age=2592000"
Header set Expires "01 Jan 2112 00:00:00 GMT"
</IfModule>
</FilesMatch>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
Here is the Wordpress directory .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /laksh/3/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /laksh/3/wordpress/index.php [L]
</IfModule>
# END WordPress
Here is the php.ini code in both the directories:
file_uploads = On
upload_max_filesize = 100M
post_max_size = 100M
The uploaded images won't even display in pages or posts.
Worth checking if
RedirectMatch 403 (?i)/+upload
is the cause of your images not being displayed, the wordpress path for uploaded images, containers the string upload

Enable mod_expires for browser caching

The htaccess file looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
# CSS
ExpiresByType text/css "access plus 1 week"
# Javascript
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType text/html "access plus 1 day"
</IfModule>
# END WordPress
Any reason why this wouldn't enable browser caching? I am running Centos 5 and have made sure the expires module is installed.
Try to use this... by file extension... change the max-age for your needs
and even use DEFLATE to compress the download size
# 1 YEAR = 29030400 || 2 DAYS = 172800 || 1 MIN = 60
# 1 WEEK = 604800
<filesMatch "\.(jpg|jpeg|png|gif|swf|xml|txt|css|js|ico|pdf|flv|html|htm)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
#compress
<filesMatch "\.(js|css|json|html|xml)$">
SetOutputFilter DEFLATE
</filesMatch>

htaccess rewrite part of url and leave rest as it is

I need to rewrite part of my url as a parameter and part as a path. Is it possible and if so can anyone please help me
To be more specific I have an url like this:
www.mysite/products/producer:some+producer/category:some+category/color:red,blue,yellow
and what I need is
www.mysite/products.php/producer:some+producer/category:some+category/color:red,blue,yellow
To make things more interesting depending on user query path after www.mysite/products/ can by shorter or longer
If I had constant number of parameters I would write something like that
RewriteRule ^products/([a-zA-Z-_0-9]+)/([a-zA-Z-_0-9]+)/?$ products.php/$1/$2 [L]
but as a number of parameters changes I have no idea what to do
That's my whole htaccess so far
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.pl
RewriteRule ^(.*)$ http://www.mysite.pl/$1 [R=permanent,L]
RewriteRule ^products/(.+)/?$ /products.php/$1 [NE,L]
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
AddDefaultCharset UTF-8
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"
Header append Cache-Control "public"
</IfModule>
## EXPIRES CACHING ##
Method #1 just changes products and keeps everything else the same
RewriteRule ^products/$ products.php [NC,L,B,QSA]
Method #2
RewriteRule ^products/producer:(.*)/category:(.*)/color:(.*)$ products.php?producer=$1&category=$2&color=$3 [NC,L]
And here's probably what your htaccess file should look like.
Options -MultiViews
RewriteEngine On
# Prevents directory browsing
Options -Indexes
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
# your 404 page
ErrorDocument 404 /path/to/your/404file.php
RewriteRule ^products/$ products.php [NC,L,B,QSA]
You can just use a .+ check:
RewriteRule ^products/(.+)/?$ /products.php/$1 [NE,L]
Putting the floating directives in their respective module checks:
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.pl
RewriteRule ^(.*)$ http://www.mysite.pl/$1 [R=permanent,L]
RewriteRule ^products/(.+)/?$ /products.php/$1 [NE,L]
</IfModule>
AddDefaultCharset UTF-8
<IfModule mod_filters.c>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 month"
Header append Cache-Control "public"
</IfModule>
## EXPIRES CACHING ##

Why am I getting a Leverage Browser Caching error on Google PageSpeed Insights

The page is www.catsmeowcruises.com/beta
I'm using Apache2 and have enabled both headers and expires and then restarted the server. My .htaccess page looks like this
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year”
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month”
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
and is placed /var/www/html with the website in /var/www/html/catsmeowcruises.com/beta
However, I still get errors about Leverage Browser Caching

VirtualHost working only in home page with Codeigniter

I'm facing some problems with Virtual Hosts under Apache 2.2.
I want to host development versions of some sites in my local environment (some of them using codeigniter) and be able to access them using a ".dev" extension, so I can go to:
- http://myproject.dev to access the local version or
- http://myproject.com to access production version
I've set up some name-based virtual hosts as follows:
NameVirtualHost localhost
<VirtualHost localhost>
DocumentRoot ".../workspace.web/"
ServerName localhost
</VirtualHost>
NameVirtualHost myproject.dev
<VirtualHost myproject.dev>
DocumentRoot ".../workspace.web/myproject.com/htdocs"
ServerName myproject.dev
</VirtualHost>
and set my hosts file
127.0.0.1 psychologuenice.dev
The home page is working fine, but subdirectories are crashing in codeigniter. For example
myproject.dev/whatever
returns a 404 error.
I'm not sure if any of the rules in htaccess could be causing this, or is just due to a bad understanding of what I'm doing here. My htaccess looks like this:
#RewriteEngine on
#RewriteCond $1 !^(index\.php|robots\.txt|images|css|js|captcha|inc|html|tmp|captcha)
#RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [QSA,L]
</IfModule>
# BEGIN Compress text files
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
# END Compress text files
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
Could someone give any clue?