简体   繁体   English

多个页面的单个.htaccess使用不同的URL重定向

[英]single .htaccess for multiple pages redirect with differnt url

i am changing my website and its old pages were like bellow 我正在更改我的网站,其旧页面像波纹管一样

http://mydomain.com/keyword_city.html

while i read that its better to use - in page for batter SEO, so i am thinking to use new new page name like bellow 虽然我读到它更好用-在面糊SEO的页面中,所以我在考虑使用新的新页面名称,例如波纹管

http://mydomain.com/keyword-city.html

first of all i want to know is this better idea to change page URL? 首先,我想知道更改页面URL的更好主意吗? and if i change my URL does this effect on page ranking ? 如果我更改URL,这会对网页排名产生影响吗?

i want to know how to write single .htaccess so that any request coming for old page will redirect to new URL, the only difference in old and new URL will be _ to - 我想知道如何编写单个.htaccess以便对旧页面的任何请求都将重定向到新URL,新旧URL的唯一区别是_ to -

Thanks 谢谢

I think you are probably looking for: 我认为您可能正在寻找:

Redirect 301 /keyword_city.html /keyword-city.html

to be placed in your .htaccess file. 放在您的.htaccess文件中。

As other people have mentioned though, probably not going to help a great deal when it comes to SEO. 正如其他人提到的那样,在SEO方面可能不会有很大帮助。 One thing that could however is using rich snippets/structured data: 但是,可能要使用的丰富代码段/结构化数据是一件事:

https://support.google.com/webmasters/answer/99170?hl=en https://support.google.com/webmasters/answer/99170?hl=zh_CN

Can be a lot of effort to do but would really help your presence on Google especially. 可能需要做很多工作,但确实可以帮助您在Google上占有一席之地。

添加到.htacess的以下代码应将所有下划线_重定向到连字符-

RewriteRule (.*)_(.*) $1-$2 [N] 

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

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