根网址显示& quot; 404-找不到文件或目录 [英] root URL shows "404 - File or directory not found

查看:76
本文介绍了根网址显示& quot; 404-找不到文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的博客的根URL显示为"404-找不到文件或目录".在更改了永久链接设置并应用了日期和名称"之后,这种情况立即发生了.

The root URL of my blog shows "404 - File or directory not found.". It happened immediately after I changed by permalink settings and applied "day and name".

如果我将永久链接设置更改为默认,则一切正常.

If I change my permalink settings to Default then everything works fine.

当我使用 MyDomain.com/page 时,它可以完美地工作,但是,当我尝试尝试 MyDomain.com/page 时,它会引发404错误.

It works perfectly when I use MyDomain.com/page however when I just try MyDomain.com/page it throws 404 error.

下面的链接告诉我一个解决方案,但由于我的网站位于共享主机上,因此对我来说这是不可能的.它在IIS 7上.

Following link tells me a solution but it is not possible for me as I have my site on shared hosting. It is on IIS 7.

任何帮助将不胜感激.

谢谢

推荐答案

基本上,为了使永久链接正常工作,您需要将请求重写为index.php,以便可以解析正确的参数并向下发送.因此,不同的Web服务器应包含不同的重写规则.

Basically, for the permalink to work, you need to rewrite requests to index.php, so the right parameters can be parsed and sent downwards. Therefore, different web server should include different rewrite rules.

例如,对于Nginx服务器,您需要将以下重写规则设置为wordpress根

For instance, for nginx servers, you need to set the following rewrite rules to the wordpress root

try_files $uri $uri/ /index.php?q=$request_uri;

我不是很熟悉IIS,但是根据 http://www.iis.net/learn/extensions/url-rewrite-module/enabling-pretty-permalinks-in-wordpress ,您应该可以通过以下方式启用永久链接:

I'm not very family with IIS, but according to http://www.iis.net/learn/extensions/url-rewrite-module/enabling-pretty-permalinks-in-wordpress, you should be able to enable permalink by adding:

<rewrite>
    <rules>
        <rule name="Main Rule" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php" />
        </rule>
    </rules>
</rewrite>

到system.webServer部分.

to system.webServer section.

我知道nginx设置可以用,因为我自己在使用它.您可以在自己的服务器上尝试IIS规则.

I know the nginx setting works because I'm using it myself. You can try the IIS rule on your own server.

这篇关于根网址显示&amp; quot; 404-找不到文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆