1

CentOS 6.4 64-bit
Apache 2.4.6
PHP-FPM 5.5.4

Homepage from root loads fine http://csillamvilag.com
But all other pages return 404 (CMS is WordPress).
I am also able to access and log into WordPress backend.

None of the WordPress pages except home page are working (all returning 404) e.g. http://csillamvilag.com/csillamtetovalas/csillamtetovalas-tanfolyamok/
http://csillamvilag.com/viszonteladok/
http://www.csillamvilag.com/forumok/

None of the OpenCart pages are working (all returning 404)
e.g. http://www.csillamvilag.com/shop/hu/

The issue seems to be with URL rewriting...

If we try to access a file directly or through the ugly URL, it seems more or less ok, e.g. http://csillamvilag.com/shop/index.php?route=product/product&product_id=231

But if we try the "pretty URL" or "SEO URL" then it doesn't,
e.g. http://www.csillamvilag.com/shop/hu/halvany-lila-strasszko-3mm
(this "pretty URL" corresponds to the same page as the ugly URL example above)

This indicates a URL rewrite issue in Apache. The rewrite rules within /home/.htaccess which affect WordPress and /home/shop/.htaccess which affect OpenCart seem to be ok. e.g. WordPress/root .htaccess is:

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

Apache is running as user apache.
All relevant WordPress and OpenCart files are owned by user apache.

access_log

127.0.0.1 - - [07/Nov/2013:02:54:07 +0100] "GET /server-status HTTP/1.1" 404 211

error_log is a couple of GB big, but here's a snippet

[Fri Nov 08 01:19:03.018295 2013] [core:info] [pid 35359:tid 139812315064064] [client 180.76.5.161:18109] AH00128: File does not exist: /home/shop/en/rhinestones-diamante/peach-rhinestones-3mm
[Fri Nov 08 01:19:03.615994 2013] [authz_core:debug] [pid 35359:tid 139812105266944] mod_authz_core.c(828): [client 66.249.78.16:53716] AH01628: authorization result: granted (no directives)
[Fri Nov 08 01:19:03.616037 2013] [proxy_fcgi:debug] [pid 35359:tid 139812105266944] mod_proxy_fcgi.c(120): [client 66.249.78.16:53716] AH01060: set r->filename to proxy:fcgi://127.0.0.1:9000/home/kepek/index.php/tag/1/h%C3%ADres
[Fri Nov 08 01:19:03.616054 2013] [proxy:debug] [pid 35359:tid 139812105266944] mod_proxy.c(1100): [client 66.249.78.16:53716] AH01143: Running scheme fcgi handler (attempt 0)
[Fri Nov 08 01:19:03.616061 2013] [proxy_fcgi:debug] [pid 35359:tid 139812105266944] mod_proxy_fcgi.c(944): [client 66.249.78.16:53716] AH01076: url: fcgi://127.0.0.1:9000/home/kepek/index.php/tag/1/h%C3%ADres proxyname: (null) proxyport: 0
[Fri Nov 08 01:19:03.616067 2013] [proxy_fcgi:debug] [pid 35359:tid 139812105266944] mod_proxy_fcgi.c(954): [client 66.249.78.16:53716] AH01078: serving URL //127.0.0.1:9000/home/kepek/index.php/tag/1/h%C3%ADres [Fri Nov 08 01:19:03.616073 2013] [proxy:debug] [pid 35359:tid 139812105266944] proxy_util.c(2020): AH00942: FCGI: has acquired connection for () [Fri Nov 08 01:19:03.616081 2013] [proxy:debug] [pid 35359:tid 139812105266944] proxy_util.c(2072): [client 66.249.78.16:53716] AH00944: connecting //127.0.0.1:9000/home/kepek/index.php/tag/1/h%C3%ADres to 127.0.0.1:9000 [Fri Nov 08 01:19:03.616131 2013] [proxy:debug] [pid 35359:tid 139812105266944] proxy_util.c(2194): [client 66.249.78.16:53716] AH00947: connected /home/kepek/index.php/tag/1/h%C3%ADres to 127.0.0.1:9000
[Fri Nov 08 01:19:03.783318 2013] [proxy:debug] [pid 35359:tid 139812105266944] proxy_util.c(2035): AH00943: FCGI: has released connection for (
)
[Fri Nov 08 01:19:04.099220 2013] [authz_core:debug] [pid 35359:tid 139812199675648] mod_authz_core.c(802): [client 66.249.78.16:55790] AH01626: authorization result of Require all granted: granted
[Fri Nov 08 01:19:04.099243 2013] [authz_core:debug] [pid 35359:tid 139812199675648] mod_authz_core.c(802): [client 66.249.78.16:55790] AH01626: authorization result of : granted
[Fri Nov 08 01:19:04.099261 2013] [core:info] [pid 35359:tid 139812199675648] [client 66.249.78.16:55790] AH00128: File does not exist: /home/shop/en/facepaints/mehron-paradise-facepaints

httpd.conf

ServerRoot "/usr/local/apache2"

Listen 80

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule unique_id_module   modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule security2_module modules/mod_security2.so

<IfModule unixd_module>
user apache
group www-data
</IfModule>

ServerAdmin handle@domain.com

ServerName domain.com:80

<Directory />
   AllowOverride all
</Directory>

DocumentRoot "/home"

<Directory "/home">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel debug

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
CustomLog "logs/access_log" common
</IfModule>

<IfModule alias_module>
    Alias /php5.cgi /usr/local/bin/php-cgi  
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
</IfModule>

<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

Include conf/extra/httpd-vhosts.conf

<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

AccessFileName .htaccess
OC2PS
  • 539
  • 2
  • 8
  • 21
  • 1
    Please provide relevant error log messages, apache configuration and similar details. Otherwise, this question may be considered off-topic. – jeffatrackaid Nov 07 '13 at 14:11
  • @jeffatrackaid Thanks for the suggestion. Added conf and error log – OC2PS Nov 08 '13 at 01:31

1 Answers1

2

This chunk of code in your httpd.conf is the culprit:

<Directory "/home">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

The .htaccess won’t be loaded if AllowOverride None is set. It should be changed to AllowOverride All:

<Directory "/home">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Then restart your Apache service & all should be good.

And “Allow Override” refers to how an .htaccess file can override Apache server settings. More info on this page.

Giacomo1968
  • 3,522
  • 25
  • 38
  • Thanks! That fixed the 404, but now the whole site (even pages that were loading earlier) is returning 500 Internal Server Error! – OC2PS Nov 08 '13 at 02:24
  • You probably munged the .htaccess file. Just get a new copy from anywhere & use a pure text editor. Also, look in your log file to see what is happening. – Giacomo1968 Nov 08 '13 at 02:33
  • 1
    Yup, it was a sucky .htaccess....apparently, WordPress rewrite rules were written again and again in it with a part messed up...so I fixed it and set it as immutable. Next task, figuring out why WordPress rules keep getting added to htaccess over and over till .htaccess dies and kills the site...I guess that's a separate question... – OC2PS Nov 08 '13 at 02:44
  • Well, WordPress seems to attempt to self-repair itself at times? I really am not a big expert on WordPress internals, but have migrated tons of WordPress sites to know exactly each simple “gotcha” like this. Ping me in a few months when I have more deep WordPress experience under my Unix admin belt. – Giacomo1968 Nov 08 '13 at 02:54
  • I am talking about repeating rewrite rules hundreds and thousands of times in .htaccess within a space of a couple of hours! Lots of people have faced this...solution suggested was add_filter( 'flush_rewrite_rules_hard', '__return_false' ); and that didn't help so as last resort I had to turn to setting .htaccess as immutable. Will ping you in a few months :-) – OC2PS Nov 08 '13 at 02:59