【发布时间】:2013-09-24 21:38:26
【问题描述】:
我已经建立了一个美德电子商务网站。 一切正常,htaccess 和重定向,商店在
http://www.domainname.com/it/store/
但“唯一”的问题是两个网址都有效:
http://www.domainname.com/it/store/article.html
和(注意没有“商店”)
http://www.domainname.com/it/article.html
与谷歌一起创建问题,总体而言,在此模式下 article.html 继承主页(横幅等)的设置。
所以,我会通过 htaccess 将任何发送到 URL 的请求重定向到带有 /store 的 URL。
.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.
【问题讨论】:
标签: regex .htaccess redirect mod-rewrite rewrite