重定向URL不存在的子文件夹的根(Redirect URL non existent subfold

2019-10-18 06:55发布

我从www.site.com/shop/子根感动我的网站。 现在的“ ”文件夹不存在了,我想重定向人谁还是去site.com/shop/whateverhtml到site.com/whateverhtml我已经尝试了不同的重写规则,但没有运气。

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

或像这样

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

谢谢。

Answer 1:

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

要么

RewriteRule ^shop(/.*)?$ $1 [R=301,L]


Answer 2:

重定向

这需要你做出一个空shop的文件夹。 在文件夹中创建一个名为HTML文件index.html 。 访问时,用户将在这里直接http://site.com/shop 。 在该文件中,把这个:

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

这将重定向到http://site.com/

取景

您可以用在页面上展示另一个页面<iframe> 一个<iframe>示出另一页,在同一页内,没有重定向。 你仍然需要保持车间的文件夹。 在这里面,把index.html的与此内容:

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

这将创建一个网页,site.com的一个iframe



文章来源: Redirect URL non existent subfolder to root