Jon
Jon

Reputation: 12992

Per-server rewriterules not working

I've got a VirtualHost directive in /etc/apache2/openpanel.d/www.example.com.conf:

<VirtualHost *:80>
   ServerAdmin        "[email protected]"
   DocumentRoot       /home/openpanel-admin/sites/www.example.com/public_html
   ServerName         www.example.com
   ServerAlias        example.com
   <Directory /home/openpanel-admin/sites/www.example.com/public_html>
   AllowOverride      All
   Allow from all
   </Directory>
   Include /etc/apache2/openpanel.d//www.example.com.inc/[^.#]*
   Include /etc/apache2/openpanel.d//global.inc
</VirtualHost>

And I've the following in /etc/apache2/openpanel.d/www.example.com.inc/RewriteRules

<Directory /home/openpanel-admin/sites/www.stallfinder.com/public_html>
        Options +FollowSymlinks
        RewriteEngine On

        RewriteRule agricultural-show-c780.html /search/event/agricultural-shows/1/ [R=301,L]
        RewriteRule antique-fair-c596.html /search/event/antique-and-collectors-fairs/1/ [R=301,L]
        RewriteRule baby-and-toddler-fairs-c896.html /search/event/baby-and-toddler-fairs/1/ [R=301,L]
        RewriteRule book-fair-c631.html /search/event/book-fairs/1/ [R=301,L]

        # etc... there are ~3000 of these
</Directory>

And I've got an .htaccess file in /home/openpanel-admin/sites/www.example.com/public_html:

Options +FollowSymlinks

RewriteEngine On
RewriteBase /

# Search pages
RewriteRule ^search/(stallholder|event)/?$ /find-$1.php [L]
RewriteRule ^search/(stallholder|event)/([^/]+)/([0-9]+)/? /$1.php?name=$2&id=$3 [L]

But the RewriteRules in the include file (RewriteRules) don't appear to be parsed/used.

The file is being included because I can put non-allowed stuff in there and apache will fail to load the config file, but if I turn on Apache redirect logging, then I only see [perdir] lines as if all the RewriteRules I've got in the RewriteRules include aren't being processed.

The global.inc file is empty, and the RewriteRules in my .htaccess file work fine.

Any clue what I'm doing wrong?

Upvotes: 0

Views: 242

Answers (1)

LazyOne
LazyOne

Reputation: 165188

Try adding RewriteOptions directive into your .htaccess to allow executing rewrite rules on parent (upper) level.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions

Upvotes: 1

Related Questions