mod rewrite rule failing

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

mod rewrite rule failing

Post by John Cartwright »

Code: Select all

RewriteEngine on
      RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Using this rule on apache 1.3 works okay, but when I transfer this to a apache 2 server I am getting an Internal Server Error. I'm not very good at regex, and I can't quite figure out a way to replicate this rule for apache 2 compliance. Any ideas?

Also, yes, Mod rewrite is loaded as a module.

Thanks :P
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

I'm assuming that you're attempting to use clean url's on your site. I've found that the following .htaccess works like a dream.

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule index.php[QSA,L]
(QSA will append the query string to the url, so $_GET will still work for legacy scripts)
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

I wouldn't expect a 500 from your rewrite so maybe ...
Note: Enabling rewrites in per-directory context
To enable the rewriting engine for per-directory configuration files, you need to set ``RewriteEngine On'' in these files and ``Options FollowSymLinks'' must be enabled. If your administrator has disabled override of FollowSymLinks for a user's directory, then you cannot use the rewriting engine. This restriction is needed for security reasons.
FollowSymLinks is required under both Apache 1.x and 2.
Post Reply