对于通过 .htaccess 的 SEO URL,扩展名也需要进行 301 处理吗?
经过研究,我得出了一些利用 SEO URL 的结论。对于基于半静态 .php
的网站,其文件名例如 index.php
、about.php
、contact.php< /code> 等我使用 htaccess
mod_rewrite
规则,例如 'www.mysite.com/about
' 可以用来代替 'www.mysite .com/about.php
'。在这种情况下,我的所有菜单和链接都指向 SEO URL。
但我发现,即使我的网站中没有任何内容引用 .php
扩展名,如果我直接输入它们,它们就会保留。因此,我可以使用 /about
或 /about.php
访问 about 页面,每个页面都会显示为输入的内容。阅读这里的帖子似乎这是一个常见问题。
我的问题是,这有关系吗?如果我的网站中没有任何内容在链接或菜单中引用 .php
扩展名,我是否需要担心重复的内容?
有人告诉我需要在 htaccess 中添加一些内容,例如:
redirect 301 /about.php http://www.mysite.com/about
为每个页面添加一些内容以消除这种可能性,但我不明白在这种情况下这是否真的是一个问题?
After researching, I have come to some conclusions for utilizing SEO URLs. For semi-static .php
based sites that have file names such as index.php
, about.php
, contact.php
etc I am using htaccess mod_rewrite
rules so that for example 'www.mysite.com/about
' can be used in place of 'www.mysite.com/about.php
'. In such cases, all of my menus and links are then pointing at the SEO URL.
What I have found out though, is that even though nothing in my site references the .php
extensions, if I enter them directly, they stick. So, I can get to the about page using /about
or /about.php
, and each will show as entered. It seems reading through posts here that this is a common issue.
My question is, does this matter? If nothing in my site references the .php
extensions in a link or menu, do i need to be worried about duplicate content??
I was told I need to add something in htaccess like:
redirect 301 /about.php http://www.mysite.com/about
for each page to eliminate the possibility but I don't understand if this is really an issue in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两个问题:
Q1. “这有关系吗”?
答案:如果您以前从未公开过 .php URL,则不会。如果有,那么答案将更改为“是”。
Q2。什么.htaccess?
回答:
Two Questions:
Q1. "Does this matter"?
Answer: Not if you've never exposed the .php URLs before. If you have, then the answer changes to "yes".
Q2. What .htaccess?
Answer:
如果您的 URL 中有一些与内容相关的关键字,并且它们在 Google Bot 可以解释它们的意义上不过分动态(请查看 Google Webmastertools 和 阅读此内容)。
所以我不会担心“mysite.com/about”与“mysite.com/about.php”。我宁愿注意避免重复内容,如果您想要更改 URL。
以下是更多链接供进一步参考:
Your URLs are SEO friendly if there are some keywords in it that relate to the content and if they are not overly dynamic in a sense that Google Bot can interpret them (take a look at the Google Webmastertools and read this).
So I would not worry about "mysite.com/about" versus "mysite.com/about.php". I would rather watch out to avoid duplicate content if you want to change the URLs.
Here are some more links for further reference: