wordpress 在此服务器上找不到请求的 URL /about
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13149418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The requested URL /about was not found on this server
提问by user1096057
The home page of my wordpress website seems to be displaying correctly but if you click through to any of the other pages I get the following error message:
我的 wordpress 网站的主页似乎显示正确,但如果您点击进入任何其他页面,我会收到以下错误消息:
Not Found
The requested URL /about was not found on this server.
Apache/2 Server at www.wildlionmedia.co.uk Port 80
I'm not sure whether it's a problem with the theme or the .htaccess file that is not being rewritten correctly.
我不确定是主题有问题还是 .htaccess 文件没有正确重写。
http://www.wildlionmedia.co.uk/
http://www.wildlionmedia.co.uk/
Any ideas how I can resolve the issue?
有什么想法可以解决这个问题吗?
# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine On
SetEnv DEFAULT_PHP_VERSION 53
DirectoryIndex index.cgi index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine Off
RewriteBase /wildlionmedia.co.uk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wildlionmedia.co.uk/index.php [L]
</IfModule>
# END WordPress
回答by Birendra Rawat
If all above point not work. Then try this one. I tried it. It's working for me.
如果以上所有点都不起作用。那就试试这个吧。我尝试过这个。它对我有用。
- Go /etc/httpd/conf/httpd.conf.
- Change the AllowOverrideNone to AllowOverride All.
- Restartthe apache server.
- 去/etc/httpd/conf/httpd.conf。
- 将AllowOverrideNone更改为AllowOverride All。
- 重启apache服务器。
UPDATE 2017
2017 年更新
For new versions of apache the file is called apache2.conf
对于新版本的 apache,该文件名为apache2.conf
So to access the file, type sudo nano /etc/apache2/apache2.confand change the correspondent line inside block <Directory /var/www >
因此,要访问该文件,请键入sudo nano /etc/apache2/apache2.conf并更改块内的对应行<Directory /var/www >
回答by markratledge
That's not a typical Wordpress rewrite block. This is:
这不是典型的 Wordpress 重写块。这是:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
See http://codex.wordpress.org/Using_Permalinks#Where.27s_my_.htaccess_file.3F
见http://codex.wordpress.org/Using_Permalinks#Where.27s_my_.htaccess_file.3F
Where's my .htaccess file? WordPress's index.php and .htaccess files should be together in the directory indicated by the Site address (URL) setting on your General Options page. Since the name of the file begins with a dot, the file may not be visible through an FTP client unless you change the preferences of the FTP tool to show all files, including the hidden files. Some hosts (e.g. Godaddy) may not show or allow you to edit .htaccess if you install WordPress through the Godaddy Hosting Connection installation.
Creating and editing (.htaccess) If you do not already have a .htaccess file, create one. If you have shell or ssh access to the server, a simple touch .htaccess command will create the file. If you are using FTP to transfer files, create a file on your local computer, call it 1.htaccess, upload it to the root of your WordPress folder, and then rename it to .htaccess.
You can edit the .htaccess file by FTP, shell, or (possibly) your host's control panel.
我的 .htaccess 文件在哪里?WordPress 的 index.php 和 .htaccess 文件应该放在由您的常规选项页面上的站点地址 (URL) 设置指示的目录中。由于文件名以点开头,因此文件可能无法通过 FTP 客户端看到,除非您更改 FTP 工具的首选项以显示所有文件,包括隐藏文件。如果您通过 Godaddy Hosting Connection 安装 WordPress,某些主机(例如 Godaddy)可能不会显示或不允许您编辑 .htaccess。
创建和编辑 (.htaccess) 如果您还没有 .htaccess 文件,请创建一个。如果您具有对服务器的 shell 或 ssh 访问权限,一个简单的 touch .htaccess 命令将创建该文件。如果您使用 FTP 传输文件,请在本地计算机上创建一个文件,将其命名为 1.htaccess,将其上传到您的 WordPress 文件夹的根目录,然后将其重命名为 .htaccess。
您可以通过 FTP、shell 或(可能)您主机的控制面板编辑 .htaccess 文件。
The easiest and fastest thing to do it reset your permalinks in Dashboard>>Settings>>Permalinks and make sure .htaccess is writable so WordPress can write the rules itself.
最简单和最快的方法是在仪表板>>设置>>永久链接中重置您的永久链接,并确保 .htaccess 是可写的,以便 WordPress 可以自己编写规则。
And: are you aware you are calling index.cgi
as your default document rather than index.php
? That's wrong. Remove index.cgi
. Or try removing the whole line, too, because defining a default doc on your server may not be needed.
并且:您是否知道您正在调用index.cgi
作为默认文档而不是index.php
?那是错误的。删除index.cgi
。或者也尝试删除整行,因为可能不需要在您的服务器上定义默认文档。
回答by Clapham
It worked for me like this:
它对我来说是这样的:
Go to Wordpress Admin Dashboard > “Settings” > “Permalinks” > “Common settings”, set the radio button to “Custom Structure” and paste into the text box:
转到 Wordpress 管理仪表板>“设置”>“固定链接”>“通用设置”,将单选按钮设置为“自定义结构”并粘贴到文本框中:
/index.php/%year%/%monthnum%/%day%/%postname%/
and click the Save button.
并单击保存按钮。
I got this solution from this link
我从这个链接得到了这个解决方案
回答by Eric Brotto
There is a trusted answer on the Wordpress website:
Wordpress 网站上有一个值得信赖的答案:
Where's my .htaccess file?
WordPress's index.php and .htaccess files should be together in the directory indicated by the Site address (URL) setting on your General Options page. Since the name of the file begins with a dot, the file may not be visible through an FTP client unless you change the preferences of the FTP tool to show all files, including the hidden files. Some hosts (e.g. Godaddy) may not show or allow you to edit .htaccess if you install WordPress through the Godaddy Hosting Connection installation.
Creating and editing (.htaccess)
If you do not already have a .htaccess file, create one. If you have shell or ssh access to the server, a simple touch .htaccess command will create the file. If you are using FTP to transfer files, create a file on your local computer, call it 1.htaccess, upload it to the root of your WordPress folder, and then rename it to .htaccess.
You can edit the .htaccess file by FTP, shell, or (possibly) your host's control panel.
The following permalink rewrite code should be included in your .htaccess file (since WordPress 3.0):
我的 .htaccess 文件在哪里?
WordPress 的 index.php 和 .htaccess 文件应该放在由您的常规选项页面上的站点地址 (URL) 设置指示的目录中。由于文件名以点开头,因此文件可能无法通过 FTP 客户端看到,除非您更改 FTP 工具的首选项以显示所有文件,包括隐藏文件。如果您通过 Godaddy Hosting Connection 安装 WordPress,某些主机(例如 Godaddy)可能不会显示或不允许您编辑 .htaccess。
创建和编辑 (.htaccess)
如果您还没有 .htaccess 文件,请创建一个。如果您具有对服务器的 shell 或 ssh 访问权限,一个简单的 touch .htaccess 命令将创建该文件。如果您使用 FTP 传输文件,请在本地计算机上创建一个文件,将其命名为 1.htaccess,将其上传到您的 WordPress 文件夹的根目录,然后将其重命名为 .htaccess。
您可以通过 FTP、shell 或(可能)您主机的控制面板编辑 .htaccess 文件。
以下永久链接重写代码应包含在您的 .htaccess 文件中(自 WordPress 3.0 起):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
*Taken from here.
*取自这里。
回答by yadavr
I deleted the previous .htaccess file and created new one by clicking on save button in Settings->Permalinks
我删除了以前的 .htaccess 文件,并通过单击 Settings-> Permalinks 中的保存按钮创建了新文件
and now that pages started working fine...
现在这些页面开始正常工作......
回答by lukeocom
The selected answer didn't solve this issue for me. So for those still scratching their head over this one, I found another solution!
所选答案并没有为我解决这个问题。所以对于那些还在为这个问题挠头的人,我找到了另一种解决方案!
In my Apache settings httpd.conf
(you can find the conf file by running apachectl -V
in your console), enabled the following module:
在我的 Apache 设置中httpd.conf
(您可以通过apachectl -V
在控制台中运行来找到 conf 文件),启用以下模块:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
And now the site works as expected.
现在该网站按预期工作。
回答by Seth 666
It worked for me like this:
它对我来说是这样的:
Go to Wordpress Admin Dashboard > “Settings” > “Permalinks” > “Common settings”, set the radio button to “Custom Structure” and paste into the text box:
转到 Wordpress 管理仪表板>“设置”>“固定链接”>“通用设置”,将单选按钮设置为“自定义结构”并粘贴到文本框中:
/index.php/%year%/%monthnum%/%day%/%postname%/
and click the Save button.
并单击保存按钮。
回答by Deepesh Thapa
Hie,
嗨,
Although late If anybody suffering from the similar issues here is what you can do to allow permalinks by modifying your virtual host file or whereever you are hosting your WP sites.
虽然晚了 如果有人遇到类似问题,您可以通过修改虚拟主机文件或托管 WP 站点的任何位置来允许永久链接。
So basically everything works fine - you set up permalinks to post and suddenly the url dissapears. You went to a lot of disscussion forums (Like me) tried a lot of modifying and got "Permission to server 403" errors or URL not found error. All you have to do is go to the host file, for example 000-default.conf if using a default virtual host or your config file inside sites-enabled,
所以基本上一切正常——你设置了永久链接来发布,突然 url 消失了。你去了很多讨论论坛(像我一样)尝试了很多修改并得到“服务器权限 403”错误或未找到 URL 错误。您所要做的就是转到主机文件,例如 000-default.conf 如果使用默认虚拟主机或启用站点的配置文件,
use in the directory section :
在目录部分使用:
<Directory "path/to/dir">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Donot use the following inside directory
不要使用以下内部目录
Order allow,deny
Allow from all
The Order and Allow directives are deprecated in Apache 2.4.
Apache 2.4中不推荐使用 Order 和 Allow 指令。
Likewise you can setup the directory in /etc/apache2/apache2.conf set the directory for your path and donot use the above - this will cause permission 403 error.
同样,您可以在 /etc/apache2/apache2.conf 中设置目录,为您的路径设置目录,不要使用上述目录 - 这将导致权限 403 错误。
In addition to that you will need to enable mod_rewrite for apache
除此之外,您还需要为 apache 启用 mod_rewrite
回答by Keith
FWIW: I rebuilt a LAMP server from scratch and installed WordPress. I had the same issue after saving my Permalink setting to generate the .htaccess file. Turns out that mod_rewrite was not enabled. I ran across this post on Digital Ocean.
FTA:
FWIW:我从头开始重建 LAMP 服务器并安装了 WordPress。保存我的永久链接设置以生成 .htaccess 文件后,我遇到了同样的问题。原来没有启用 mod_rewrite。我在 Digital Ocean 上看到了这篇文章。
自贸协定:
First, we need to activate mod_rewrite. It's available but not enabled with a clean Apache 2 installation.
首先,我们需要激活 mod_rewrite。它可用,但未通过干净的 Apache 2 安装启用。
$ sudo a2enmod rewrite
This will activate the module or alert you that the module is already enabled. To put these changes into effect, restart Apache.
这将激活模块或提醒您该模块已启用。要使这些更改生效,请重新启动 Apache。
$ sudo systemctl restart apache2
回答by Ako
Here is another version for Wordpress, original one did not work as intended.
这是 Wordpress 的另一个版本,原始版本没有按预期工作。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [END]
RewriteCond ^(index\.php)?$ [OR]
RewriteCond \.(gif|jpg|png|ico|css|js)$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ - [END]
RewriteRule ^ /index.php [L]
</IfModule>
# END WordPress
Reference from this Github repository, modified a bit. After excessive testing this rule does not solve all problems.We have a Wordpress webshop, which has 40 plugins and somewhere is there a rewrite clash. I sincerely hope next version of Wordpress has no URL rewrites.
来自此 Github存储库的参考,稍作修改。经过过度测试,此规则并不能解决所有问题。我们有一个 Wordpress 网上商店,它有 40 个插件,并且在某个地方存在重写冲突。我真诚地希望下一版本的 Wordpress 没有 URL 重写。
RewriteRule ^index\.php$ - [L]
The ^
signifies start of the string, \
escapes .
or it would mean any character, and $
signifies end of the string.
在^
表示开始字符串中,\
转义.
或将意味着任何字符,和$
字符串的表示结束。
^index\.php$
if http(s)://hostname/index.php-
do nothing [END]
flag can be used to terminate not only the current round of rewrite processing but prevent any subsequent rewrite processing.
^index\.php$
if http(s)://hostname/ index.php-
do nothing[END]
标志不仅可以用来终止当前轮次的重写处理,还可以防止任何后续的重写处理。
RewriteCond ^(index\.php)?$ [OR]
In RewriteCond
using $1
as a test string references to captured contents of everything from the start to the end of the url http(s)://hostname/bla/bla.php. If used in substitution or condition it references to captured backreference. RewriteRule (bla)/(ble\.php)$ -
for http(s)://hostname/bla/ble.phpcaptures bla
into $1
and ble.php
into $2
. Multiple capture groups can be accessed via $3..N
.
在RewriteCond
使用$1
字符串的引用作为测试一切从开始捕获的内容到该URL的HTTP(S)的端部://主机名/ BLA / bla.php。如果在替换或条件中使用,它会引用捕获的反向引用。RewriteRule (bla)/(ble\.php)$ -
为HTTP(S)://主机名/ BLA / ble.php捕捉bla
到$1
和ble.php
进入$2
。可以通过 访问多个捕获组$3..N
。
( )
groups several characters into single unit, ?
forces the match optional.
[OR]
flag allows you to combine rewrite conditions with a logical OR relationship as opposed to the default AND.
( )
将几个字符组合成一个单元,?
强制匹配可选。
[OR]
标志允许您将重写条件与逻辑 OR 关系相结合,而不是默认的 AND。
In short, if bla/bla.phpcontains index.php OR next condition
简而言之,如果bla/bla.php包含 index.php OR 下一个条件
RewriteCond \.(gif|jpg|png|ico|css|js)$ [NC,OR]
( )
groups several characters into single unit, |
separates characters to subgroups and conditions them if any one of.
[NC]
flag causes the RewriteRule to be matched in case-insensitive manner.
( )
将几个字符组合成一个单元,|
将字符分隔为子组,如果有任何一个,则对它们进行条件化。
[NC]
flag 导致 RewriteRule 以不区分大小写的方式进行匹配。
In short, if bla/bla.phpends with any of the filetypes OR next condition
简而言之,如果bla/bla.php以任何文件类型或下一个条件结尾
RewriteCond %{REQUEST_FILENAME} -f [OR]
Server-Variables are variables of the form %{ NAME_OF_VARIABLE } where NAME_OF_VARIABLE can be a string taken from the following list:
服务器变量是 %{ NAME_OF_VARIABLE } 形式的变量,其中 NAME_OF_VARIABLE 可以是从以下列表中获取的字符串:
%{REQUEST_FILENAME}
is full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI. Depending on the value of AcceptPathInfo, the server may have only used some leading components of the REQUEST_URI to map the request to a file.
%{REQUEST_FILENAME}
是与请求匹配的文件或脚本的完整本地文件系统路径,如果在引用 REQUEST_FILENAME 时服务器已经确定了该路径。否则,例如在虚拟主机上下文中使用时,与 REQUEST_URI 的值相同。根据 AcceptPathInfo 的值,服务器可能仅使用 REQUEST_URI 的一些主要组件将请求映射到文件。
-f
check for regular file. Treats the test string as pathname and tests whether or not it exists.
-f
检查常规文件。将测试字符串视为路径名并测试它是否存在。
In short, if bla/bla.phpis a file OR next condition
简而言之,如果bla/bla.php是一个文件或下一个条件
RewriteCond %{REQUEST_FILENAME} -d
-d
check for directory. Treats the test string as a pathname and tests whether or not it exists.
-d
检查目录。将测试字符串视为路径名并测试它是否存在。
In short, if bla/bla.phpis a directory
总之,如果bla/bla.php是一个目录
RewriteRule ^(.*)$ - [END] not as in Github [S=1]
This statement is only executed when one of the condition returned true.
此语句仅在条件之一返回 true 时执行。
.
match any character *
zero or more times.
.
匹配任何字符*
零次或多次。
The [S]
flag is used to skip rules that you don't want to run. The syntax of the skip flag is [S=N]
, where N
signifies the number of rules to skip (provided the RewriteRule matches). This can be thought of as a goto statement in your rewrite ruleset. In the following example, we only want to run the RewriteRule if the requested URI doesn't correspond with an actual file.
该[S]
标志用于跳过您不想运行的规则。跳过标志的语法是[S=N]
,其中N
表示要跳过的规则数(前提是 RewriteRule 匹配)。这可以被认为是重写规则集中的 goto 语句。在以下示例中,我们只想在请求的 URI 与实际文件不对应时运行 RewriteRule。
In short, do nothing
简而言之,什么都不做
RewriteRule ^ /index.php [L]
The [L]
flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.
该[L]
标志导致 mod_rewrite 停止处理规则集。在大多数情况下,这意味着如果规则匹配,则不会处理其他规则。这对应于 Perl 中的最后一个命令,或 C 中的 break 命令。使用此标志来指示应立即应用当前规则而不考虑其他规则。
In short, rewrite every path as http(s)://hostname/index.php
简而言之,将每个路径重写为 http(s)://hostname/ index.php
I fetched this little doc together from apaches.org documentation. Links below.
我从 apaches.org 文档中一起获取了这个小文档。链接如下。