从URL中删除/重写2个目录名称

时间:2013-07-17 21:56:19

标签: apache .htaccess

我需要重写或重定向这样的网址:

  

http://www.mydomain.com/shop/product/keep-this-please

  

http://www.mydomain.com/keep-this-please

我商店(Magento)目录中的htaccess已经有了这个:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /shop/

## always send 404 on missing files in these folders
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

## never rewrite for existing files, directories and links
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

## rewrite everything else to index.php
    RewriteRule .* index.php [L]
</IfModule>

如何仅使用/ shop / product /重写URL?

1 个答案:

答案 0 :(得分:1)

在RewriteBase行下方插入此行:

RewriteRule ^product/(.+)$ /$1 [L,R=302,NC]