简体   繁体   中英

Remove / Rewrite 2 directory names from URL

I need to rewrite or redirect URLs like this:

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

to

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

and the htaccess in my shop (Magento) directory already has this:

<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>

How do I rewrite just the URLs with the /shop/product/ in it?

将此行插入到RewriteBase行的正下方:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM