简体   繁体   English

mod_rewrite上的“文件不存在”错误(WordPress永久链接)

[英]“File does not exist” error on mod_rewrite (WordPress permalink)

I'm trying to configure WordPress permalinks on Linode server running Ubuntu. 我正在尝试在运行Ubuntu的Linode服务器上配置WordPress永久链接。 The permalinks are not working even after doing the basic tricks for configuring them. 即使在完成配置它们的基本技巧之后,永久链接也无法正常工作。

.htaccess -file has been given permission "777" and WP has rewritten it: .htaccess -file已被授予“777”权限并且WP已经重写了它:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mydirectory/mysubdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mydirectory/mysubdirectory/index.php [L]
</IfModule>

# END WordPress

I have configured "etc/apache2/sites-available/default in a following way: 我以下列方式配置了“etc / apache2 / sites-available / default”:

DocumentRoot /var/www
<Directory />
   Options FollowSymLinks
       AllowOverride ALL
</Directory>
   <Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride ALL
       Order allow,deny
       allow from all
   </Directory>
   <Directory /var/www/mydomin.com/public_html/mydirectory/>
      RewriteEngine On
      AllowOverride ALL
   </Directory>

As you can see I've tried to set "AllowOverride" to different folders. 如您所见,我试图将“AllowOverride”设置为不同的文件夹。 I just gave it a shot, thought that maybe something is overriding the rule for certain folders. 我只是给了它一个镜头,认为可能有些东西覆盖了某些文件夹的规则。

I have ran "a2enmod rewrite" command on Terminal and mod_rewrite is enabled. 我在终端上运行了“a2enmod rewrite”命令,启用了mod_rewrite。

I have restarted my Apache every time I've made changes. 每次我做出更改时,我都重新启动了Apache。

When I navigating on my WordPress site I get "Page not found" error. 当我在我的WordPress网站上导航时,出现“找不到页面”错误。 Apache error log says following: Apache错误日志说明如下:

File does not exist: /var/www/mydomain.com/public_html/mydirectory/mysubdirectory/

What am I missing here? 我在这里错过了什么?

The below settings can go in your VirtualHost directive for the site in question. 以下设置可以在您的VirtualHost指令中找到相关网站。 In most cases this is located in a separate file and referenced from the main conf file for the server. 在大多数情况下,它位于单独的文件中,并从服务器的主conf文件中引用。

RewriteEngine On
AllowOverride ALL

Generally speaking you want to keep all of the settings for each site in their own file. 一般来说,您希望将每个站点的所有设置保存在自己的文件中。 So if you need to tweak anything else do it in the file containing the VirtualHost directive for that site. 因此,如果您需要调整其他任何内容,请在包含该站点的VirtualHost指令的文件中执行此操作。 It makes it much easier to troubleshoot/maintain in the future. 它使将来更容易进行故障排除/维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM