对于通过 .htaccess 的 SEO URL,扩展名也需要进行 301 处理吗?

发布于 2024-12-01 07:59:08 字数 728 浏览 1 评论 0原文

经过研究,我得出了一些利用 SEO URL 的结论。对于基于半静态 .php 的网站,其文件名例如 index.phpabout.phpcontact.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难如初 2024-12-08 07:59:08

两个问题:
Q1. “这有关系吗”?
答案:如果您以前从未公开过 .php URL,则不会。如果有,那么答案将更改为“是”。

Q2。什么.htaccess?
回答:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [R=301,L]

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:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [R=301,L]
全部不再 2024-12-08 07:59:08

如果您的 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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文