Thursday, May 7, 2015



I've been having problems with Permalinks in a WordPress site. I found many others having the same problem, but no solutions identified. I'd been working on this for weeks, learning all kinds of wonderful stuff about apache2's mod_rewrite, regular expressions and so forth. All appropriately logged, saved, and posted below.

But then I got caught up in a bunch of events and left it for a week.

When I came back to the problem I noticed that my published site was processing permalinks correctly, while my localhost version was not.

OK! Now I can compare and find the problem.

First I did a side by side comparison of httpd.conf. No difference.

So then I looked at the WordPress permalink settings:
Settings → Permalinks

The disfunctional site had them set to Post name:

The functional had it set to Custom:

So I added the /index.php/ and now it works.

PATHINFO permalinks look very much like mod_rewrite permalinks but for one exception: they have /index.php inserted before them.

Otherwise, they are the same as the "pretty" mod_rewrite permalinks, and are similarly flexible. Anything that mod_rewritepermalinks can do, PATHINFO permalinks can do, with the help of that /index.php part.

To activate PATHINFO permalinks, start your permalink structure with index.php/.

So it appears that we must use PATHINFO Permalinks, not mod_rewrite Permalinks

But why?

More to learn. At least now it is working. Hope this helps others.

============= Previous Post =============

Apache 2.4.10... module rewrite is not responding.

I'm sure it's something simple, but weeks of work have been evaded in finding it.

This is a monster. I have checked all of the following thoroughly:

• The firewall is not the problem. Turning it on or off has no effect.

• .htaccess is not the problem as it reflects what everyone says it should and one is generated by WordPress.

• WordPress is not the problem as mod_rewrite does not respond outside of WordPress.

• PHP is not the problem. PHP scripts all run successfully.

I've worked through all the options of the fundamental Apache2 documentation for mod_rewrite:

     I've set
          LogLevel alert rewrite:trace4
               I find no errors in
                    or anywhere else.

RewriteBase Directive

     I've set this correctly in each affected .htaccess file

Require Directive
     This is generated by WordPress and by analysis is correct.

RewriteEngine Directive
     Both .htaccess files contain
             RewriteEngine On

RewriteRule Directive
The RewriteRule directive is the real rewriting workhorse.
Yeh, ok, except it isn't working. But the rules for /nptbeyond/ are written by WP, those for /test/ are as posted, so who am I to question them. Let's look for another cause.

So everything is totally in order, no shortcuts. But it doesn't work.

httpd.conf might be the problem, but it is very simple. Other than include statements and all the outcommented statements the only parts I've changed read:

# forbid access to the entire filesystem by default

    Options None
    AllowOverride None
Require all denied

# New section

DocumentRoot /srv/www/htdocs

Options Indexes FollowSymLinks Multiviews
AllowOverride All
Require all granted

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them ;
# The tilde ~ indicates that the text inside the quotes is a PCRE
# The cap ^ indicates to include all precedent paths
# The backslash \ renders the literal value of the period . otherwise
# it would be looking for any single charater before:

    Require all denied

So all seems right.

But it is not.

No comments: