Jump to content

mod_rewrite and DirectoryIndex


andygeers

Recommended Posts

Hi there,

 

My hosting company recently upgraded me from Apache 1 to Apache 2, and I've started seeing some quite different behaviour with my mod_rewrite stuff.

 

Here's my .htaccess file:

 

DirectoryIndex blog.php
ErrorDocument 404 /404.html

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Rewrite current-style URLs of the form 'showpage.php?url=x'.
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteCond %{REQUEST_URI} !^.*showpage\.php.*$
  RewriteCond %{REQUEST_URI} !^.*ppotd_sm\.php.*$
  RewriteCond %{REQUEST_URI} !^.*rss/.*$
  RewriteCond %{REQUEST_URI} !^.*scripts/.*$
  RewriteRule ^(.*\.(php|html))$ showpage.php?url=$1 [L,QSA]

</IfModule>

 

Now, previously with Apache 1, if you went to http://mysite.com/  then the DirectoryIndex would first take effect (http://mysite.com/blog.php) and then the RewriteRule would turn that into http://mysite.com/showpage.php?url=/blog.php

 

Now with Apache 2, if you go to http://mysite.com/blog.php it gets rewritten as expected, but if you go to http://mysite.com/ it serves you the vanilla blog.php file, without rewriting it to showpage.php. It's as though the DirectoryIndex stops it also doing the RewriteRule.

 

Any thoughts?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.