【问题标题】:htaccess redirect for virtuemart美德玛特的 htaccess 重定向
【发布时间】: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


    【解决方案1】:

    将此规则放在RewriteBase 行的下方:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/[^/]+/store/ [NC]
    RewriteRule ^([^/]+)/(.+)$ /$1/store/$2 [R=301,L]
    

    【讨论】:

    • 您的代码站点似乎无法正确调用 css、jquery 等 :(
    • 更新:css、jquery 等不起作用,因为 Joomla 引擎现在在“www.domain.com/store/templates”中搜索它们。当然“商店”不存在......
    • 更新:css、jquery 等不起作用,因为 Joomla 引擎现在在“www.domain.com/store/templates”中搜索它们。当然“商店”不存在......
    • 我们在正确的道路上!现在,一切似乎都工作了,但不是主页...主页需要“仅”http//www.domain.com/it(没有商店),否则我有空白页...非常感谢!
    • 完美!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多