我无法获得.htaccess重写规则来使用我的Prestashop网站

时间:2015-03-25 11:55:06

标签: .htaccess url url-rewriting rewrite prestashop

好的,我使用自动生成器为.htaccess文件中的prestashop站点生成自定义URL,但它不起作用。有什么想法吗?

原始网址为:

http://www.example.com/de/suche?controller=search&orderby=position&orderway=desc&search_query=mutter&submit_search=OK

重写的网址应为:

http://www.example.com/search/position/desc/mutter/OK.html

我在.htaccess文件中的重写规则是:

RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /de/suche?controller=$1&orderby=$2&orderway=$3&search_query=$4&submit_search=$5 [L]

1 个答案:

答案 0 :(得分:0)

您应该从规则中删除[L]标记。它会阻止任何其他规则应用,但您需要将此新路由传递给Prestashop调度程序。

<IfModule mod_rewrite.c>
    RewriteEngine on

    #Domain: test.example.com
    RewriteRule . - [E=REWRITEBASE:/]
    RewriteRule ^api$ api/ [L]
    RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
    # Images
    RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
    # [...]

# You need to put your condition here without the [L] flag
# And before the Dispatcher
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /de/suche?controller=$1&orderby=$2&orderway=$3&search_query=$4&submit_search=$5
# Your URL is then rewritten to Prestashop standard format
# and will be sent to the following Dispatcher.

    # Dispatcher
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
相关问题