Jump to content

url rewrite httaccess www +/- :looking for recommendation


Recommended Posts

Hello

 

I have generated my httaccess via BO PS1.4.9 and added a php parameter. Now, I want to make certain that their is no doublicate content seen by any search engine.

 

I found this code and I would like to apply it if can give me an OK since I am a newbie on this matter :)

 

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]

 

This is mine that has the option to redirect any part of my site to https. At the moment it is out commented but I might want to combine it with the www redirection. I am using the www. version.

 

 

# .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

#RewriteCond %{HTTPS} !=on
#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
php_value max_input_vars 50001


<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on
RewriteRule ^([A-Za-z0-9/-]+).tpl$ https://www.supa-dupa-shop.com/index.php [L] #this is the condition to redirect url
# URL rewriting rules
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg [L]
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$1$2.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /img/c/$1.jpg [L]
RewriteRule ^c/([0-9]+)/[a-zA-Z0-9-]+\.jpg$ /img/c/$1.jpg [L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /category.php?id_category=$1&noredirect=1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 [QSA,L]
RewriteRule ^seite-nicht-gefunden$ /404.php [QSA,L]
RewriteRule ^adresse$ /address.php [QSA,L]
RewriteRule ^adressen$ /addresses.php [QSA,L]
RewriteRule ^authentifizierung$ /authentication.php [QSA,L]
RewriteRule ^verkaufshits$ /best-sales.php [QSA,L]
RewriteRule ^warenkorb$ /cart.php [QSA,L]
RewriteRule ^kontaktieren-sie-uns$ /contact-form.php [QSA,L]
RewriteRule ^discount$ /discount.php [QSA,L]
RewriteRule ^auftragsverfolgung-gast$ /guest-tracking.php [QSA,L]
RewriteRule ^bestellungsverlauf$ /history.php [QSA,L]
RewriteRule ^kennung$ /identity.php [QSA,L]
RewriteRule ^hersteller$ /manufacturer.php [QSA,L]
RewriteRule ^mein-Konto$ /my-account.php [QSA,L]
RewriteRule ^neue-Produkte$ /new-products.php [QSA,L]
RewriteRule ^bestellung$ /order.php [QSA,L]
RewriteRule ^bestellungsverfolgung$ /order-follow.php [QSA,L]
RewriteRule ^schnell-bestellung$ /order-opc.php [QSA,L]
RewriteRule ^bestellschein$ /order-slip.php [QSA,L]
RewriteRule ^kennwort-wiederherstellung$ /password.php [QSA,L]
RewriteRule ^angebote$ /prices-drop.php [QSA,L]
RewriteRule ^suche$ /search.php [QSA,L]
RewriteRule ^sitemap$ /sitemap.php [QSA,L]
RewriteRule ^shops$ /stores.php [QSA,L]
RewriteRule ^zulieferer$ /supplier.php [QSA,L]
</IfModule>
# Catch 404 errors
ErrorDocument 404 /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>


 

 

Can you give me advice please?

Link to comment
Share on other sites

Hello,

 

First make sure to make a copy of your current and working .htaccess in case anything go wrong.

 

Then insert only the following two lines:

 

 

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]

 

Just after:

 

 

<IfModule mod_rewrite.c>
# URL rewriting module activation
RewriteEngine on

 

But I do not really understand why you want to do this manually. If you want to use the 'www.domain.com' version, you just have to define your domain as 'www.domain.com' in your BO > preferences > SEO & URLs...

 

Note any change you will make manually will be wiped out if you regenerate your .htaccess.

 

As for your https rule, it is not needed and will not make your site more secure. Just turn the HTTPS in your BO so the login page redirects to https by itself.

 

 

Hope this helps.

 

 

Cheers!

Link to comment
Share on other sites

Muad'Dib

 

thank you your answer was a precise help so to speak.

The idea came up to do this manually because a SEO tool told me that I should make this change in order to not being treated disadvantageously considering rank ...

I wonder why because I have created this httacces via BO on the first hand. And my site is named www.myshop.com in the bo. I cannot actually read this httaccess scripts but may be you can discern that from my code above?

 

I mean I only want to optimize and make sure I am giving away chances but if you tell me that I do not have make any changes to given file.

Link to comment
Share on other sites

×
×
  • Create New...