在更改网址中的单词后重定向301

时间:2022-10-20 10:09:06

the actual url structure is:

实际的url结构是:

domain.com/browse-string.html

domain.com/browse-string.html

examples of old url: domain.com/browse-nature-videos-1-date.html domain.com/browse-science-videos-1-views.html

旧网址示例:domain.com/browse-nature-videos-1-date.html domain.com/browse-science-videos-1-views.html

I have changed the world browse so the new url is

我改变了世界浏览所以新的网址是

domain.com/newword-string.html

domain.com/newword-string.html

How can I 301 redirect old to new?

我如何301将旧的重定向到新的?

Thank you in advance

先谢谢你

2 个解决方案

#1


1  

You can do a simple RewriteRule and check for the start of the string to be "browse".

您可以执行一个简单的RewriteRule并检查字符串的开头是否为“browse”。

RewriteEngine On
RewriteRule ^browse(.*)$ /newword$1 [L,R=301]

Make sure you change newword to the new word you want.

确保将newword更改为您想要的新单词。

You can test it here: http://htaccess.mwl.be/

你可以在这里测试一下:http://htaccess.mwl.be/

在更改网址中的单词后重定向301 Sorry for handwriting abilities

对不起手写能力

#2


0  

Place the following in the .htaccess file and it should work:

将以下内容放在.htaccess文件中,它应该工作:

Redirect 301 /oldfile.html /newfile.html

Edit: Since you need rule/pattern based redirection, the following thread should fix you up:

编辑:由于您需要基于规则/模式的重定向,以下线程应该修复您:

HTACCESS redirection with a word replacement in url

在url中使用单词替换的HTACCESS重定向

#1


1  

You can do a simple RewriteRule and check for the start of the string to be "browse".

您可以执行一个简单的RewriteRule并检查字符串的开头是否为“browse”。

RewriteEngine On
RewriteRule ^browse(.*)$ /newword$1 [L,R=301]

Make sure you change newword to the new word you want.

确保将newword更改为您想要的新单词。

You can test it here: http://htaccess.mwl.be/

你可以在这里测试一下:http://htaccess.mwl.be/

在更改网址中的单词后重定向301 Sorry for handwriting abilities

对不起手写能力

#2


0  

Place the following in the .htaccess file and it should work:

将以下内容放在.htaccess文件中,它应该工作:

Redirect 301 /oldfile.html /newfile.html

Edit: Since you need rule/pattern based redirection, the following thread should fix you up:

编辑:由于您需要基于规则/模式的重定向,以下线程应该修复您:

HTACCESS redirection with a word replacement in url

在url中使用单词替换的HTACCESS重定向