【问题标题】:Remove / Rewrite 2 directory names from URL从 URL 中删除/重写 2 个目录名称
【发布时间】:2013-07-16 16:00:11
【问题描述】:

我需要像这样重写或重定向 URL:

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?

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    在 RewriteBase 行下方插入此行:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-31
      • 2019-06-19
      • 2020-09-09
      • 1970-01-01
      • 2020-05-11
      相关资源
      最近更新 更多