[resolved] Configure permalinks directly in Apache httpd.conf? (3 posts)

  1. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    Is is possible to configure permalinks directly in Apache httpd.conf? I have a server situation (Apache 2.2.3 CentOS PHP5.1.6) where I can't use .htaccess for performance reasons, but can use httpd.conf.

    Also, Mod Rewrite is enabled, but AllowOverride is not, and I can't change those settings.


  2. tonychung
    Posted 6 years ago #

    Funny how the server gives you access to the httpd.conf file but not override the server settings with .htaccess. Alas, all hope is not lost.

    In your httpd.conf (or one of the included .conf files) is a reference to your website directory. It will look something like this:

    <Directory "/var/www/path/to/your/web/dir">
      Options ...

    Add the mod_rewrite directive in between the <Directory></Directory> tags to enable the permalink feature in your site:

    <Directory "/var/www/path/to/your/web/dir">
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

    For more permalink control without .htaccess support, install the redirection plugin. Without a valid .htaccess file, the options will trigger an error that I'm sure you can safely ignore. At least it worked on my test server.

  3. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    Thanks, I came across an answer at Server Fault a few days ago. .htaccess support is disabled by the sysadmin, but he was willing to change httpd.conf for me.

    But you're right, you can put the same rewrite block in httpd.conf as in .htaccess and wrap it in <directory> directives to allow it to work only on a particular directory.

    You still have to set permalinks in Settings/Permalinks so that WP and the database know about the permalink settings. And then you can ignore what WP says about the .htaccess being updated after you set permalinks. If directory permissions are such that WP can write an .htaccess file, it's best to go ahead and delete it.

    So set permalinks, copy the required changes to .htaccess and add that rewrite block to httpd.conf, reboot apache. Delete .htaccess if generated.

    But the redirection plugin you point to requires .htaccess, which are not allowed and ignored when .htaccess support is not enabled in httpd.conf

Topic Closed

This topic has been closed to new replies.

About this Topic