WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. 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.

    ideas?

  2. tonychung
    Member
    Posted 4 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 ...
      ...
      etc.
    </Directory>

    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]
      </IfModule>
    </Directory>

    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. 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