У меня есть следующий файл .htaccess в /public_html/.htaccess
:
# 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
Вот разрешение моего каталога public_html / на сервере Ubuntu 14 Wordpress 4.1 Apache 2.4 У меня есть почти идентичные сайты Wordpress с тем же файлом .htaccess, я не понимаю, почему я получаю ошибку 404 на моих страницах Wordpress - Примечание. Я могу видеть домашнюю страницу моего веб-сайта, но всякий раз, когда нажимается ссылка, возникает ошибка 404, в прошлый раз, когда это произошло, я обнаружил опечатку .htaccess, на этот раз я не уверен ..
Мои журналы ошибок и доступа имеют одинаковые разрешения, я вижу журнал доступа, записанный при посещении сайта, но без ошибок ни в журнале ошибок, ни в error_log в каталоге Wordpress public_html /
/log$ ll
total 336K
drwxr-xr-x 2 www-data root 4.0K Jun 6 18:17 .
-rw-rw-r-- 1 www-data root 1.6K Jun 9 14:14 error.log
drwxr-xr-x 6 www-data root 4.0K Jun 10 07:23 ..
-rw-rw-r-- 1 www-data root 320K Jun 10 07:42 access.log
Я не вижу ничего, кроме заметок журнала от перезапуска apache2 в журналах доступа и ошибок / etc / log / apache2
tail error.log
[Wed Jun 10 07:05:15.142372 2015] [mpm_prefork:notice] [pid 6655] AH00169: caught SIGTERM, shutting down
[Wed Jun 10 07:05:16.258882 2015] [mpm_prefork:notice] [pid 6873] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 configured -- resuming normal operations
[Wed Jun 10 07:05:16.258960 2015] [core:notice] [pid 6873] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 10 07:18:45.823428 2015] [mpm_prefork:notice] [pid 6873] AH00169: caught SIGTERM, shutting down
[Wed Jun 10 07:18:46.694270 2015] [mpm_prefork:notice] [pid 7210] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 configured -- resuming normal operations
[Wed Jun 10 07:18:46.694345 2015] [core:notice] [pid 7210] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 10 07:28:36.820319 2015] [mpm_prefork:notice] [pid 7210] AH00169: caught SIGTERM, shutting down
[Wed Jun 10 07:28:37.698102 2015] [mpm_prefork:notice] [pid 7472] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 configured -- resuming normal operations
[Wed Jun 10 07:28:37.698179 2015] [core:notice] [pid 7472] AH00094: Command line: '/usr/sbin/apache2'
sh: 1: /usr/sbin/sendmail: not found
/var/log/apache2# tail access.log
::1 - - [10/Jun/2015:07:38:20 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:21 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:22 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:23 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:24 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:25 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:38:26 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:42:03 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:42:10 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
::1 - - [10/Jun/2015:07:42:38 -0400] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.7 (internal dummy connection)"
/public_html$ ll
total 216K
-rw-r--r-- 1 www-data www-data 3.0K Jan 5 21:17 xmlrpc.php
-rw-r--r-- 1 www-data www-data 4.0K Jan 5 21:17 wp-trackback.php
-rw-r--r-- 1 www-data www-data 25K Jan 5 21:17 wp-signup.php
-rw-r--r-- 1 www-data www-data 11K Jan 5 21:17 wp-settings.php
-rw-r--r-- 1 www-data www-data 8.1K Jan 5 21:17 wp-mail.php
-rw-r--r-- 1 www-data www-data 33K Jan 5 21:17 wp-login.php
-rw-r--r-- 1 www-data www-data 2.7K Jan 5 21:17 wp-load.php
-rw-r--r-- 1 www-data www-data 2.4K Jan 5 21:17 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 2.9K Jan 5 21:17 wp-cron.php
-rw-r--r-- 1 www-data www-data 4.9K Jan 5 21:17 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 271 Jan 5 21:17 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 4.9K Jan 5 21:17 wp-activate.php
-rw-r--r-- 1 www-data www-data 418 Jan 5 21:17 index.php
drwxr-xr-x 9 www-data www-data 4.0K Jan 5 22:11 wp-admin
-rw-r--r-- 1 www-data www-data 20K Feb 18 22:05 license.txt
drwxr-xr-x 12 www-data www-data 4.0K Mar 1 21:57 wp-includes
-rw-r--r-- 1 www-data www-data 7.1K May 7 06:30 readme.html
-rw-r--r-- 1 www-data www-data 25K May 25 06:23 error_log
drwxr-xr-x 6 www-data root 4.0K Jun 10 07:23 ..
drwxr-xr-x 8 www-data www-data 4.0K Jun 10 07:26 wp-content
-rw-r--r-- 1 www-data www-data 3.3K Jun 10 07:26 wp-config.php
-rw-r--r-- 1 www-data www-data 236 Jun 10 07:28 .htaccess
drwxr-xr-x 5 www-data www-data 4.0K Jun 10 07:28 .
/var/www/html/
total 24K
drwxr-xr-x 2 www-data root 4.0K Mar 28 16:00 backups
drwxr-xr-x 2 www-data root 4.0K Jun 6 18:17 log
drwxr-xr-x 5 root root 4.0K Jun 9 07:12 ..
drwxr-xr-x 6 www-data root 4.0K Jun 10 07:23 .
drwxr-xr-x 5 www-data www-data 4.0K Jun 10 07:28 public_html
Я подозреваю, что проблема теперь связана с AllowOveride All
в моих файлах конфигурации, поэтому я обновил их всеми возможностями, но все еще получаю ошибки 404:
cat 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
#DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory "/var/www/html">
AllowOverride All
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
cat foobar.com.conf
# domain: foobar.com
# public: /var/www/foobar.com/public_html/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@foobar.com
ServerName www.foobar.com
ServerAlias foobar.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/foobar.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/foobar.com/log/error.log
CustomLog /var/www/html/foobar.com/log/access.log combined
<Directory /var/www/html/foobar.com/public_html>
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Я также попытался изменить файл .htaccess, обратите внимание, что я увеличивал редактирование построчно, ни одна строка не изменилась за пределами оператора if.
cat .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L
# 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
Разрешение .htaccess
-rw-r--r-- 1 www-data www-data 399 Jun 11 07:21 .htaccess
В моих журналах ошибок по-прежнему ничего нет, мой синтаксис верен 000-default.conf
и foobar.conf
файлы? Я использовал https://askubuntu.com/questions/429869/is-this-a-correct-way-to-enable-htaccess-in-apache-2-4-7-on-ubuntu-12-04
Что нужно проверить:
sudo a2enmod rewrite
)Я подозреваю, что первый вариант решит вашу проблему.