1

我已经建立了一个美德商城电子商务。一切正常,htaccess 和重定向,商店在

http://www.domainname.com/it/store/

但“唯一”的问题是两个 url 都是有效的:

http://www.domainname.com/it/store/article.html

和(注意没有“商店”)

http://www.domainname.com/it/article.html

与谷歌产生问题,总体而言,在这种模式下 article.html 继承主页的设置(横幅等)。

因此,我将通过 htaccess 将发送到 URL 的任何请求重定向到带有 /store 的 URL,而不使用 store。

.htaccess 是 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.
4

1 回答 1

1

将此规则放在以下RewriteBase行:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/[^/]+/store/ [NC]
RewriteRule ^([^/]+)/(.+)$ /$1/store/$2 [R=301,L]
于 2013-09-24T09:21:14.063 回答