Forum Moderators: phranque
# replace www.EXAMPLE.COM with your website address.
# be sure to add any extra paths required to locate the index.php
# then relocate this file to the root of your store's folders, and rename it as .htaccess
ErrorDocument 404 http://www.EXAMPLE.COM/index.php?main_page=page_not_found
ErrorDocument 404 [b]/[/b]index.php?main_page=page_not_found http://www.example.com/index.php?main_page=popup_image&pID=48000 type URLs indexed. Disallow: /?main_page=popup_image
Disallow: /index.php?main_page=popup_image # trailing slash
# If URL-path does not contain a period or end with a slash
#RewriteCond %{REQUEST_URI} !(\.|/$)
# add a trailing slash
#RewriteRule (.*) http://www.example.com/$1/ [R=301,L]
#
# Redirect non-www domain requests to www domain
RewriteCond %{HTTP_HOST} ^example\.
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# trailing slash
# If URL-path does not contain a period or end with a slash
#RewriteCond %{REQUEST_URI} !(\.|/$)
# add a trailing slash
# RewriteRule .* http://example.com%{REQUEST_URI}/ [R=301,L]
#
# Canonicalize the domain
# Redirect non-www domain requests to www domain
RewriteCond %{HTTP_HOST} ^www\.example\.
RewriteRule (.*) http://example.com%{REQUEST_URI} [R=301,L]
# Domain canonicalisation
# Redirect all non-www domain requests, and www with port number, to www domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] # Domain canonicalisation
# Redirect all www domain requests, and non-www with port number, to non-www domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule (.*) http://example.com%{REQUEST_URI} [R=301,L] [edited by: jdMorgan at 2:50 am (utc) on Mar 7, 2010]
[edit reason] Edited at member's request. [/edit]
# Index Redirect for /index.php with no parameters
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/? [R=301,L] # Index Redirect for /index.php?main_page=index and /?main_page=index URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=index\ HTTP/
RewriteRule ^(index\.php)?$ http://www.example.com/? [R=301,L] # Canonical Redirect non-www to www [EXCLUDE /admin requests]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
index.php and index.php?main_page=index and ?main_page=index and index.php?main_page=index&cPath= and ?main_page=index&cPath= too. # Index Redirect for /(zencart/)index.php with no parameters
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(zencart/)?index\.php\ HTTP/
RewriteRule ^(zencart/)?index\.php$ http://www.example.com/? [R=301,L]
#
# Index Redirect for /(zencart/)(index.php)?main_page=index(&cPath=) URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(zencart/)?(index\.php)?\?main_page=index(&cPath=)?\ HTTP/
RewriteRule ^(zencart/)?(index\.php)?$ http://www.example.com/? [R=301,L]
#
# Redirect all /zencart/ folder URL requests
RewriteRule ^zencart/(.*)$ http://www.example.com/$1 [R=301,L]
#
# Canonical Redirect non-www to www [EXCLUDE /admin requests]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L] ../ construct that is not required. You might need to reinstall the code, or at least edit some configuration data somewhere. [edited by: g1smd at 10:57 pm (utc) on Mar 19, 2010]
www.example.com/index.php?main_page=product_info&cPath=567&products_id=45678 which already exposes the system to multiple potential Duplicate Content problems. www.example.com/index.php?main_page=product_info&cPath=567&products_id= with a blank products_id value. Once the 'prev' or 'next' links are clicked to visit the broken URL, the user sees a 'product cannot be found' error message. Using Analytics it could be seen that a fair number of people exit the site at just such a URL. /index.php?main_page=[b]product_info[/b]&cPath=[b]567[/b]&products_id=[i]<blank>[/i] with blank products_id value or /index.php?main_page=[b]product_info[/b]&cPath=[b]567[/b] with products_id parameter missing, and redirects the user to the www.example.com/index.php?main_page=[b]index[/b]&cPath=[b]567[/b] category index instead. # Fixes broken 'prev' and 'next' links from removed 'special offers' and other such product pages
# Index Redirect for /(index.php)?main_page=product_info&cPath=<anything>(&products_id=<blank>) URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=[b]product_info[/b]&cPath=[b]([0-9_]+)[/b](&products_id=)?\ HTTP/
RewriteRule ^(index\.php)?$ http://www.example.com/index.php?main_page=[b]index[/b]&cPath=[b]%2[/b] [R=301,L]
# Don't rewrite requests for any URIs ending with a file extension (ending with .xyz)
RewriteCond $1 !\.[a-z]{2,4}$ [NC]
# Don't rewrite requests for admin,, editors, cpanel, or frontend directories
RewriteCond $1 !^(admin\ name|editors|cpanel|frontend) [NC]
# Handle all other URIs using Zen Cart (index.php)
RewriteRule ^(.*)$ index.php [L]