I have multiple sites running on a Mac Mini server running OSX Server (El Capitan). I am running WordPress on one site and have not been able to get the permalinks work properly.

I followed the instructions in this post: https://wordpress.org/support/topic/getting-htaccess-working-for-permalinks-on-mac-osx-server?replies=3

  • I have my web root folder set at /Library/Server/Web/Data/Sites
  • I created an .htaccess in my websites directory (/Library/Server/Web/Data/Sites/website)
  • I enabled mod_rewrite and set the AllowOverride setting to All on my httpd.conf file.
  • I made sure that the httpd.conf file is writable.
  • When I change the permalink (to format /%postname%/) and hit save, I get a message saying "Permalink structure updated."
  • When I save a new page, it appears to give the correct permalink structure (sample-page/)
  • When I try to open the page, I get a 404 error.

Based on the suggestion below, I took a look at my server log. The log gave this output:

[Sat Aug 13 09:15:28.081255 2016] [autoindex:error] [pid 7076] [client 17.151.38.202:49836] AH01276: Cannot serve directory /Library/Server/Web/Data/Sites/www.ecumene.com/: No matching DirectoryIndex (index.html,index.php,default.html) found, and server-generated directory index forbidden by Options directive
[Sat Aug 13 09:16:44.879836 2016] [mpm_prefork:notice] [pid 6994] AH00169: caught SIGTERM, shutting down
[Sat Aug 13 09:16:49.596197 2016] [mpm_prefork:notice] [pid 7117] AH00163: Apache/2.4.18 (Unix) LibreSSL/2.2.7 mod_wsgi/3.4 Python/2.7.10 PHP/5.5.36 configured -- resuming normal operations
[Sat Aug 13 09:16:49.596277 2016] [core:notice] [pid 7117] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/httpd_server_app.conf -E /var/log/apache2/error_log'
[Sat Aug 13 09:16:50.291312 2016] [mpm_prefork:notice] [pid 7117] AH00169: caught SIGTERM, shutting down
[Sat Aug 13 09:16:55.105614 2016] [ssl:warn] [pid 7157] AH01916: Init: (www.ecumene.com:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Sat Aug 13 09:16:55.181103 2016] [ssl:warn] [pid 7157] AH01916: Init: (www.ecumene.com:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Sat Aug 13 09:16:55.242694 2016] [mpm_prefork:notice] [pid 7157] AH00163: Apache/2.4.18 (Unix) LibreSSL/2.2.7 mod_wsgi/3.4 Python/2.7.10 PHP/5.5.36 configured -- resuming normal operations
[Sat Aug 13 09:16:55.242740 2016] [core:notice] [pid 7157] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/httpd_server_app.conf -E /var/log/apache2/error_log -D WEBSERVICE_ON'
postdrop: warning: unable to look up public/pickup: No such file or directory

This is a fresh install of WordPress with no plugins. How do I get this to work properly? I have been struggling with this for a while now.

Thank you.

up vote 2 down vote accepted

I'd check a few things

Apache2 logs

  • open a terminal
  • Check error logs at tail -f /var/log/apache2/error_log
  • Check access logs at tail -f /var/log/apache2/access_log

WordPress

  • Check .htaccess has correct rules for basic setup
  • enable wp debugging to see if you can log further errors when the redirect happens

this is how you enable WP logging

  • Add in wp-config.php before the /* That's all, stop editing! Happy blogging. */ these 3 lines of code

This will create a debug.log file in wp-content folder

define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Then try to access your url and check your logs for any information while you get your 404 error.

Check these things and report back if you find something odd. Your setup seems fine to me as is. But you might be missing something else. That's why checking your logs should provide more info if you have a miss configuration.

EDIT

I believe your problem is with the DirectoryIndex directive

Cannot serve directory /Library/Server/Web/Data/Sites/www.ecumene.com/: No matching DirectoryIndex (index.html,index.php,default.html) found, and server-generated directory index forbidden by Options directive

Wordpress is using the index.php file behind the scene to convert permalinks into query vars. But currently your web server is not set to read index.php files (most likely it will only allow index.html files) so you will need to add this file to your DirectoryIndex directive

locate your httpd.conf (likely in /private/etc/apache2/httpd.conf)

then

  • sudo nano /private/etc/apache2/httpd.conf
  • Search the file ( ctrl + w ) for DirectoryIndex

and add index.php to this block

<IfModule dir_module>
  DirectoryIndex index.php index.html
</IfModule>
  • Exit nano using ctrl + x and answering y to save the modified file
  • Test your config sudo apachectl -t
  • Restart apache sudo apachectl restart

This will tell apache to look in your site directory for index.php files first, if none found, it will try for index.html files.

This should fix your issue.

  • I looked at the server log and updated the question above. I checked the .htaccess in my website directory (/Library/Server/Web/Data/Sites/www.ecumene.com) at the file has the correct text as per the link you sent. I added the code to the wp-config.php file, but it didn't create a debug.log file in the wp-content folder. – mattbowlby Aug 13 '16 at 19:07
  • Edited the answer, this should fix your issue – bynicolas Aug 13 '16 at 19:47
  • Everyone thing is working fine now. I saw another problem - when using Mac OS X Server (El Capitan), the server app references a different .conf file (/Library/Server/Web/Config/apache2/httpd_server_app.conf). I had to set AllowOverride to All there and then restart the server app. Thanks. – mattbowlby Aug 13 '16 at 20:58
  • Glad you got it working, AllowOverride All tells apache to read the htaccess file in the directory, so yeah that is important too. Cheers! – bynicolas Aug 13 '16 at 21:23
  • Just wanted to add, the reason why you didn't see a file debug.log is because you didn't have PHP errors when refreshing the page. – bynicolas Aug 13 '16 at 22:32

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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