I want to know why the personal links (for url Rewriting) are not working with Prestashop...
I Did a test with (add in the end of the file):
RewriteRule ^test$ /index.php [L]
But it doesn't work. I searched on the web but I don't find something...
The default URL rewriting by Prestashop works but I can't add other links
Can you help me ? Do you need more information ?
Thanks
The htaccess file :
# ~~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>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Images
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
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]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
<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>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
## Ajout manuelle ##
# RewriteRule ^kit-chaine-afam.htm$ /content/6-kit-chaine-afam [L]
RewriteRule ^www.accessoires-de-la-moto.com/kit-chaine-afam.htm$ /index.php?id_cms=6&controller=cms [L]
RewriteRule ^/test$ /index.php [L]
RewriteRule ^www.accessoires-de-la-moto.com/test2$ www.accessoires-de-la-moto.com/index.php [L]
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
RewriteRule ^test3$ %{ENV:REWRITEBASE}index.php [L]
Have you tried a simple "RedirectPermanent" in your htacces file ?
RedirectPermanent /old_page_urlp /new_page_url
is it working ?
These two
RewriteRule ^www.accessoires-de-la-moto.com/kit-chaine-afam.htm$ /index.php?id_cms=6&controller=cms [L]
RewriteRule ^www.accessoires-de-la-moto.com/test2$ www.accessoires-de-la-moto.com/index.php [L]
cannot work, because the domain is not part of the URL-path pattern.
This rule should work
RewriteRule ^/test$ /index.php [L]
but this rule above from Prestashop
RewriteRule ^.*$ - [NC,L]
prevents it.
You can move your rule above the Prestashop definitions
RewriteRule ^test$ /index.php [L]
# ~~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>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.accessoires-de-la-moto.com$
...
and then, the /test rule will work as expected. But be careful to not interfere with Prentashop's rules.
You just go Preferences->SEO & URLs. In the Setup URLs section, switch Friendly URLs to yes.
You can change the URL rewriting configurations and rules from the admin panel:
Preferences -> SEO & URLs -> SCHEMA OF URLS
Related
This simple rule should redirect to url without one word (picture-display):
RewriteRule en/catalog/picture-display/(.*)$ en/catalog/$1 [L,NC,R=302]
But it redirect from www.example.com/en/catalog/picture-display/something to www.example.com/en. What I am doing bad?
Before this rule I have this. Would not influence it?
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
EDIT
Whole .htaccess:
path/.htaccess
Header unset ETag
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^/?$ /public/index.php [L]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$ [NC]
RewriteRule ^(.*)/?$ /public/$1
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [QSA,NC,L]
htaccess to route from documentRoute:
path/public/.htaccess (document route) - there is index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Result of cmd
Please try add rule:
RewriteRule ^en/catalog/picture-display/(.*)$ en/catalog/$1 [L,NC,R=302]
before line with RewriteRule ^/?$ /public/index.php [L]
Please try following htaccess rules in your file. Please make sure to clear your browser cache before testing your URLs.
Header unset ETag
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(ico)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [F,L]
RewriteCond %{REQUEST_URI} !^/public [NC]
RewriteRule ^(.*)/?$ /public/$1 [L]
RewriteRule ^/?$ /public/index.php [L]
RewriteRule ^public /public/index.php [QSA,NC,L]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ $1/$2 [L,NC,R=302]
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ $1/$2 [L,NC,R=302]
Keep your path/public/.htaccess (document route) like as follows:
RewriteOptions Inherit
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Have it this way in your site root .htacccess:
RewriteEngine On
RewriteRule ^\.htaccess/?$ - [NC,F]
# add www and turn on https in same rule
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=302,L,NE]
RewriteRule ^(cs/katalog)/obrazkove-zobrazeni/(.*)/?$ /$1/$2 [L,NC,R=302]
RewriteRule ^(en/catalog)/picture-display/(.*)/?$ /$1/$2 [L,NC,R=302]
RewriteRule ^/?$ /public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/ [NC]
RewriteRule .* public/$0 [L]
Correct htaccess which do what I wanted is:
RewriteEngine On
RewriteRule ^cs/katalog/obrazkove-zobrazeni/(.*)/?$ /cs/katalog/$1 [L,NC,R=302]
RewriteRule ^en/catalog/picture-display/(.*)/?$ /en/catalog/$1 [L,NC,R=302]
RewriteRule ^\.htaccess/?$ - [NC,F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$ [NC]
RewriteRule ^(.*)/?$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [QSA,NC,L]
I would like to thank to #RavinderSingh13 and others which tried out help me, but their solutions didn't work unlike mine.
I read many similar questions but I did not find a solution. I want to redirect HTTP to HTTPS on the home page only.
http://example.com to https://example.com
I don't know anything about .htacces.
Here you can see how it looks now, it contains code to hide .php extensions, expires caching and redirect www to non-www. I found these examples online:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
#AddHandler application/x-httpd-php54 .php54 .php
AddHandler application/x-httpd-php70 .php
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
To redirect only the homepage to HTTPS (and canonicalise the www subdomain) then add the following at the top of your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+) [NC]
RewriteRule ^$ https://%1/ [R=302,L]
Note that this is a 302 (temporary) redirect. Only change it to a 301 (permanent) when you are sure it's working OK to avoid browser caching issues.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Your existing www to non-www redirect at the end of the file also needs to be modified, otherwise it will redirect the homepage back to HTTP. This should also be moved to the top of your .htaccess file, immediately after the HTTP to HTTPS redirect.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.+)$ http://%1/$1 [R=301,L]
Note that I changed ^(.*)$ to ^(.+)$ to match 1 or more characters - thus avoiding the homepage. You can also simplify this to (.+) (ie. remove the anchors) if you wish. Regex is greedy by default, the anchors are superfluous.
Summary
RewriteEngine On
# Only redirect homepage to HTTPS (and remove www subdomain)
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+) [NC]
RewriteRule ^$ https://%1/ [R=302,L]
# Remove www subdomain on other pages (HTTP only)
# >>> This is moved from the end of the htaccess file
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule (.+) http://%1/$1 [R=302,L]
# Remainder of htaccess file....
:
:
Clear your browser cache and change 302 to 301 only once you have confirmed it's working OK.
Aside: You can remove the RewriteEngine directive that appears later in the file if you wish. This is optional, it only needs to occur once. Being at the top, before the mod_rewrite directives, is logical (but not strictly required).
I have one issue with my htaccess redirection code.
Suppose I request this url
https://example.com/about-us/
Then its redirect to non-slash link that means they redirect to
https://example.com/about-us
but what happens in between
https://example.com/about-us/ this url redirect to
https://example.com/about-us.html then redirect to
https://example.com/about-us
I want to remove this middle step from redirection.
I attached my htaccess code for better understanding
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTP_USER_AGENT} !Twitterbot [NC]
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
#RewriteCond %{HTTP_USER_AGENT} !Twitterbot [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} "blog"
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} "blog"
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}\.html -f
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
RewriteRule (.*)\.html$ $1 [R=301]
# remove trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# forward request to html file, **but don't redirect (bot friendly)**
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.html [L]
</IfModule>
#Alternate default index page
DirectoryIndex index.html
## 404 Page
ErrorDocument 404 https://example.com/404
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
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 2 days"
</IfModule>
## EXPIRES CACHING ##
# END WordPress
Thank you in advance
Keep all your redirect rules at top:
Options -MultiViews
RewriteEngine On
RewriteBase /
## remove www and turn on https in same rule
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_USER_AGENT} !Twitterbot [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L,NE]
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (\S+)\.html\ HTTP [NC]
RewriteRule ^ %1 [R=301,L,NE]
# remove trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/+$
RewriteRule ^ %1 [R=301,NE,L]
# forward request to html file, **but don't redirect (bot friendly)**
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ %{REQUEST_URI}.html [L]
# remaining rules go below this
Make sure to use a new browser for your testing or completely clear your browser cache.
About Options -MultiViews: Option MultiViews (see http://httpd.apache.org/docs/2.4/content-negotiation.html) is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So if /file is the URL then Apache will serve /file.html.
i have been contiously upgrading my htaccess file. however, there are 2 issues I just cant seem to fix. I have tried several approaches but nothing really worked for me.
my website: https://www.zeroohm.com/
my questions:
How can I remove the extra trailing slash when i go to zeroohm.com
currently, if i go to zeroohm.com, it redirects to https://www.zeroohm.com//
if i go to www.zeroohm.com/robots.txt/ , it stops me from viewing my robots.txt file (an error occured while processing this directive). how can i fix this? this problem happens to sitemap.xml and it is causing problems with webmaster tool too.
C. any ideas on improving my re-directs?
my htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} ^zeroohm\.ae$ [OR]
RewriteCond %{HTTP_HOST} ^www\.zeroohm\.ae$
RewriteRule ^/?$ "http\:\/\/www\.zeroohm\.com\/\$1\/" [R=301,L]
# check if url has www or not, add www if not available. if avaiable dont do anything.
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
#end
# force incoming traffic coming from HTTP to Https
RewriteCond %{HTTPS} !on$
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#end
#force trainling slash
RewriteBase /
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
#end of force trailing slash
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks
Options +SymLinksIfOwnerMatch
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# cache to keep it at client pc
<ifmodule mod_expires.c>
Expiresactive on
# set default
Expiresdefault "access plus 24 hours"
Expiresbytype image/jpg "access plus 1 months"
Expiresbytype image/gif "access plus 1 months"
Expiresbytype image/jpeg "access plus 1 months"
Expiresbytype image/png "access plus 1 months"
Expiresbytype text/css "access plus 1 months"
Expiresbytype text/javascript "access plus 1 months"
Expiresbytype application/javascript "access plus 1 months"
Expiresbytype application/x-shockwave-flash "access plus 1 months"
</ifmodule>
#gzip compression
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# SEO URL Settings
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\ ]*)
RewriteRule ^ /%1? [R=301,L]
You can keep these rules in your site root .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www\.)?zeroohm\.ae$ [NC]
RewriteRule ^ http://www.zeroohm.com%{REQUEST_URI} [R=301,L,NE]
# check if url has www or not, add www if not available. if avaiable don't do anything.
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
#force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule ^ - [F,L]
RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\s]*)
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^sitemap\.xml$ index.php?route=feed/google_sitemap [L,QSA,NC]
RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L,QSA,NC]
RewriteRule ^download/ /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule (.*) index.php?_route_=$0 [L,QSA]
Clear your browser cache before testing this change.
In the code above are the lines that i have in my .htaccess file. The problem is when is a single command works like a charm but when i add many commands doesnt work any of thems. Please can anyone help me to find the error.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www.marinoswood.gr$ [NC]
RewriteRule ^(.*)$ http://www.marinoswood.gr/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^185\.4\.133\.44
RewriteRule (.*) http://www.marinoswood.gr/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
<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"
</IfModule>
A few rules of thumb:
Always put your redirect rules before any internal rewrite rules, so anything with an R flag must be first
If you are using the F flag, in a rule to block access, those rules must be before all rules, including your redirect rules (ones with R flag)
Rewrite conditions only apply to the immediately following rule, so if the conditions need to be applied to multiple rules, those conditions must be repeated for each of them
Those .php rules are completely broken and need to be rewritten
Additionally, the mod_expires directives do not impact the rules.
So maybe you want something like?:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{HTTP_HOST} !^www.marinoswood.gr$ [NC]
RewriteRule ^(.*)$ http://www.marinoswood.gr/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^185\.4\.133\.44
RewriteRule (.*) http://www.marinoswood.gr/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)/$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1/$2.php -f
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php [L]
<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"
</IfModule>