Forum Moderators: phranque

Message Too Old, No Replies

Rewrite rule works locally but not on webserver

         

anikolaye

5:09 pm on Jun 19, 2009 (gmt 0)

10+ Year Member



Hi, I'm new to apache so hopefully this is simple to answer.

I have my rewrite rule as:
<Directory /var/www/quasicms>
RewriteEngine On
RewriteRule ^.*AccountHome/design/[0-9]+.*?$ core/classes/imageHandler.class.php?id=$1
</Directory>
on my local machine.

However, when I translate this to my webserver, it will not rewrite. Is the Directory tag very important with Rewrite rules? This is what I have on the server (much more complicated).

DocumentRoot /var/www/batchpcb/devel

RewriteEngine On

#allow old batch product links ..
RewriteCond %{QUERY_STRING} ^products_id=([0-9]+)(&check=.*)$
RewriteRule product_info\.php /index.php/Products/%1%2 [L]
# RewriteRule ^.*AccountHome/design/[0-9]+.*?$ core/classes/imageHandler.class.php?id=$1

<Directory /var/www/batchpcb/devel>
RewriteRule ^.*AccountHome/design/[0-9]+.*?$ core/classes/imageHandler.class.php?id=$1
Options SymLinksIfOwnerMatch
AllowOverride None
Order Deny,Allow
Deny from all
Allow from 204.188.103.98 71.218.121.241 63.224.70.252
</Directory>

I have other directories that have Deny from all without any allows... could this be my issue? I have tested the regex to know that it works correctly, I feel like this has to be a location problem or a flag problem?

g1smd

12:33 am on Jun 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** I'm new to apache so hopefully this is simple to answer. ***

I am not sure there would ever be a relationship attributed to your newness and the simplicity of the answer. :)

This rewrite could never work. At no point does any pattern matching lead to the $1 backreference being populated:

RewriteRule ^.*AccountHome/design/[0-9]+.*?$ core/classes/imageHandler.class.php?id=$1

As well as fixing that, the .* patterns and the anchoring are both unnecessary, and you must add the [L] flag to the rule.

Caterham

2:34 pm on Jun 20, 2009 (gmt 0)

10+ Year Member



. Is the Directory tag very important with Rewrite rules?

You're in per-directory context within the <directory> section (fixup hook), outside of it in per-server context (translate_name hook).

However, when I translate this to my webserver

You did not "translate"
RewriteEngine on
into your server-side <directory>-section. Hence mod_rewrite's fixup hook will decline.