Reputation: 5172
I've setup a virtuemart ecommerce. All ok with htaccess and redirect, store is in
http://www.domainname.com/it/store/
But the "only" problem is it that both url are valid:
http://www.domainname.com/it/store/article.html
and (note absence of "store")
http://www.domainname.com/it/article.html
creating problem with google and overall that in this mode article.html inherit settings of home page (banners, etc).
So, i would to redirect via htaccess any request sent to an URL without store to URL with /store.
.htaccess is default of Joomla:
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
# RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
Upvotes: 1
Views: 662
Reputation: 785481
Put this rule just below RewriteBase
line:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/[^/]+/store/ [NC]
RewriteRule ^([^/]+)/(.+)$ /$1/store/$2 [R=301,L]
Upvotes: 1