PHP 中的大写和小写 url
我在根示例中创建了文件夹: http://www.zipholidays.co.uk/Cuba 或 http://www.zipholidays.co.uk/Florida
当我输入 < a href="http://www.zipholidays.co.uk/cuba" rel="nofollow noreferrer">http://www.zipholidays.co.uk/cuba (小写的立方体),它显示找不到页面。
我正在使用 Apache 服务器。人们链接到的页面有小写、大写、混合大小写等等。我该怎么做才能使页面不区分大小写?
I have created folders in my root example: http://www.zipholidays.co.uk/Cuba or http://www.zipholidays.co.uk/Florida
When I type http://www.zipholidays.co.uk/cuba (Cube in lowercase), it shows page not found.
I'm using Apache server. People are linking to pages with lowercase, uppercase, mixed case - whatever. What do I do to make the pages case insensitive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
也许是mod_spelling? mod_spelling
mod_spelling perhaps? mod_spelling
我不会让我的网址不区分大小写。相反,我会遵循严格的准则来创建此类 URL。例如,我只会使用小写 URL 路径,并将带有大写字母的 URL 路径的请求重定向到小写变体。
您甚至可以使用 mod_rewrite (需要 将映射重写为内部
tolower
函数):I wouldn’t make my URLs case insensitive. Instead I would follow a strict guideline for creating such URLs. I would for example only use lowercase URL paths and redirect requests with URL paths with uppercase letters to the lowercase variant.
You can even do that with mod_rewrite (requires rewrite map to internal
tolower
function):如果您使页面不区分大小写,则会遇到一些重复内容的问题,因为您将有两个具有相同内容的页面。
一个好的解决方案是,当存在等效的小写字母时,在每个 404 页面上执行一些 301 重定向。
例如,在您的 404 默认页面中,您输入:
因此,当您加载 404 页面时,如果存在小写的相同 url,您将重定向到那里。否则,您可以显示您自己的缺失页面内容。
If you make your pages case insensitive, you'll have some duplicate content problems as you will have two pages with the same content.
A good solution would be to do some 301 redirect on every 404 page when the equivalent in lowercase exists.
For example in your 404 default page, you put :
So when you load a 404 page, if the same url in lower cases exists, you redirect there. Otherwise you can display your own missing page content.
也许你可以用windows代替linux作为服务器操作系统。
Linux 上的 Apache 在文件路径中区分大小写,在 URI 中也是如此。 Windows 文件系统不区分大小写,因此这并不重要。
Maybe you can replace linux for windows as the server OS.
Apache on Linux is case sensitive in the filepaths, so also in the URI's. Windows file system isn't case sensitive, so it doesn't matter there.
您不需要这样做。因为谷歌会认为你的网站上有重复的页面,并会禁止你。这是SEO科学的规则。
You do not need to do that. Because Google will think that you have duplicate pages on your site, and gonna ban you. It is the rule of SEO science.