0

I have the following .htaccess file in /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

Here are the permission of my public_html/ directory on a Ubuntu 14 server Wordpress 4.1 Apache 2.4 I have near identical Wordpress sites with the same .htaccess file, I don't understand why I am receiving a 404 error on my Wordpress pages - Note I am able to see my website homepage but whenever a link is clicked a 404 error generates, last time this happened I discovered a .htaccess typo, this time I am not sure..

My error and access logs have the same permissions, I see the access log written to as I visit the site, but no errors in the error log, nor in the error_log in the Wordpress public_html/ directory

/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

I don't see anything other than log notes from restarting apache2 in the /etc/log/apache2 access and error logs

    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

I suspect the issue is now related to the AllowOveride All directive within my configuration files, as such I have updated them with all possibilities, yet still receive the 404 errors:

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>

I also tried modifying the .htaccess file, note I incremented the editing line by line, no single line made an difference outside the if statement.

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

Permission of .htaccess

-rw-r--r-- 1 www-data www-data 399 Jun 11 07:21 .htaccess

Still nothing in my error logs, is my syntax correct on the 000-default.conf and foobar.conf files? I made use of https://askubuntu.com/questions/429869/is-this-a-correct-way-to-enable-htaccess-in-apache-2-4-7-on-ubuntu-12-04

  • 1
    You might want to post the .htaccess itself as well. – Tim Stoop Jun 10 '15 at 11:48
  • It is, posted all the way at the bottom – phillipsk Jun 10 '15 at 11:49
  • Argh scrolling windows... I hate them. – Tim Stoop Jun 10 '15 at 11:50
  • 1
    I am receiving a 404 error on my Wordpress pages You are probably missing AllowOverride All - hence the htaccess file takes no effect. You can check if the htaccess file does anything by simply typing junk in it. – AD7six Jun 10 '15 at 13:05
1

Things to check:

  • Is mod_rewrite enabled? (sudo a2enmod rewrite)
  • Does it work outside the IfModule block? Simply remove the lines and see if that changes things.

I suspect the first option will fix your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.