简体   繁体   English

301将所有文件从一个文件夹重定向到一个文件?

[英]Redirect 301 all files from a folder to one file?

Good day everyone, 今天是个好日子,

On my Wordpress website, I had a plugin that transfered external links through virtual site.com/go/abc123xyz style links. 在我的Wordpress网站上,我有一个插件可以通过virtual site.com/go/abc123xyz样式链接传输外部链接。

I have removed the plugin but obviously, when I checked G webmaster tools, there were many Not Found errors for all of those virtual links. 我已经删除了该插件,但显然,当我检查了G网站站长工具后,所有这些虚拟链接都出现了许多“未找到”错误。

All I wish to do is redirect all of those /go/links to one particular external link. 我要做的就是将所有/ go / links重定向到一个特定的外部链接。 I'm looking for a redirection rule which will redirect all links from the virtual /go/ folder to my specified link. 我正在寻找一个重定向规则,该规则会将所有链接从虚拟/ go /文件夹重定向到我指定的链接。

Would be really thankful if anyone can help me. 如果有人能帮助我,我将非常感谢。 Thanks! 谢谢!

Try adding: 尝试添加:

RewriteRule ^go/(.*) www.mysitedotcom/out/link.php?id=$1 [R=301,NC,L]

To your default htaccess file: 到您的默认htaccess文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

So it should look like this: 所以它应该看起来像这样:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^go/(.*) /out/link.php?id=$1 [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I hope that answers your question and helps you. 我希望能回答您的问题并为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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