2016-12-09 34 views
0

如何将Prestashop类别的Trailing Slash 301重定向仅使用(!)?Traling Slash重定向Prestashop类别

我有这个解决方案,但是这对所有URL都有效。

#Force trailing slash 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_URI} !(.*)/$ 

RewriteCond %{REQUEST_URI} !\.[^/]*$ 

RewriteRule ^(.*)$ /$1/ [L,R=301] 

我有这个重写我的网址。

Categories : {rewrite}/ 
Product: {category:/}{rewrite}.html 

我需要这个了404错误,如果我使用一些类别无斜线:

http://shop.domain.com/category_example -> 404 error 

必须重定向到

http://shop.domain.com/category_example/

回答

0

在后台去Preferences -> SEO & URLs并设置Route to category{id}-{rewrite:/}

这将使用尾部斜杠作为类别,并将不带斜杠的类别重定向到带斜杠的正确URL。

+0

你好,这并不工作,因为根类(指数-PHP)成为404错误。我的网址也没有ID:{rewrite}/ – redpillcoders

+0

@ user3221012如何在不使用{{id}'的情况下设置类别和产品路由? PrestaShop不允许没有它的路由,至少不是从后台设置。但是,如果您使用的是某个SEO模块,那么您可能会向开发人员询问这一点。 – TheDrot

+0

它与Dispachter和Link.php重写。这对于SEO广告系列的友好网址很重要。 – redpillcoders

0

尝试添加以下代码到你的.htaccess文件:

# Various rewrite rules. 
    <IfModule mod_rewrite.c> 
    RewriteEngine on 

    #--------------- custom redirects ----------------- 
    #hard coded 
    RewriteRule ^this_is_hot_news/index\.html http://www.mysite/news [R=301,L] 

    RewriteRule (.*)/index\.html$ http://www.mysite.nl/$1 [R=301,L] 
    RewriteRule (.*)\.html$ http://www.mysite.nl/$1 [R=301,L] 

    RewriteRule (.*)/index\.php$ http://www.mysite.nl/$1 [R=301,L] 
    RewriteRule (.*)\.php$ http://www.mysite.nl/$1 [R=301,L] 

    #end custom redirects