1

I have moved my site from www.site.com/shop/ subfolder to root. Now the "shop" folder doesn't exist anymore and I would like to redirect people who still go to site.com/shop/whateverhtml to site.com/whateverhtml I have tried different Rewrite rules but with no luck.

RewriteEngine on
RewriteRule %{REQUEST_URI} ^/shop/.*
RewriteRule shop/(.*)$ /$1 [R=301,L]

or like this

RedirectMatch 301 ^/shop/$ http://site.com/

Thanks.

4

2 回答 2

0

Redirecting

This requires you make an empty shop folder. In the folder, create an HTML file called index.html. Users will be directed here when visiting http://site.com/shop. In that file, put this:

<html>
<head>
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0; url=http://site.com/">
</head>
<body>
You are being redirected...
</body>
</html>

This will redirect them to http://site.com/.

Framing

You can show another page on the page with an <iframe>. An <iframe> shows another page, within the same page, without redirecting. You still have to keep the shop folder. In it, put index.html with this content:

<html>
<head>
<title>Shop</title>
</head>
<body>
<iframe src="http://site.com/"></iframe>
</body>
</html>

This will create a page with an iframe of site.com

于 2013-06-15T21:21:06.463 回答
0
RewriteCond %{REQUEST_URI} ^/shop(/.*)?$
RewriteRule ^(.*)$ %1 [R=301,L]

or

RewriteRule ^shop(/.*)?$ $1 [R=301,L]
于 2013-06-15T21:22:37.580 回答