.htaccess and Mod-rewrite


Recommended Posts

*cries* Does anyone know why my rules are not working.

<IfModule mod_rewrite.c>

RewriteEngine On

##Scent related rewrite rules

RewriteRule ^/?scents/new/$ scents.php?action=new [L]

RewriteRule ^/?scents/([^/\.]+)/$ scents.php?id=$1 [L]

RewriteRule ^/?scents/([^/\.]+)/([^/\.]+)/$ scents.php?id=$1&action=$2 [L]

RewriteRule ^/?scents/$ scents.php [L]

</IfModule>

The last one works, but none of the others do. With Xamp they were working fine, but now I've moved it across to Ubuntu server and they just do the last one. :\

The weird thing is, I can throw garble into the document ("asdasdas") and it still does the re-writing fine.. I can even delete my .htaccess file and it will still do the last rule. (in /var/www). I've tried looking for another .htaccess using Find, but it doesn't find any. :\

Edited by Pc_Madness
Link to comment
Share on other sites

You trying to foobar the config file, and it still working, suggests that there may be rewrite rules in the Apache config. Did you happen to add them there first and later decide to use .htaccess files?

Link to comment
Share on other sites

You trying to foobar the config file, and it still working, suggests that there may be rewrite rules in the Apache config. Did you happen to add them there first and later decide to use .htaccess files?

Nope. :( What file would I need to look in to double check? /etc/apache2/apache2.conf?

Could it be something like Apache can't find /scents/ so it tries scents.php instead?

Link to comment
Share on other sites

Yes, that would be the file.

Now that I've double checked your rules, you have nothing but rules without conditions to apply said rules. It looks as if you're trying to check the condition and apply the rule on each RewriteRule line. Anytime I've toyed with mod_rewrite, I've always had a condition (or multiple conditions) before applying the rule, so that may be your issue.

Link to comment
Share on other sites

Nope. :( What file would I need to look in to double check? /etc/apache2/apache2.conf?

Could it be something like Apache can't find /scents/ so it tries scents.php instead?

It seems like this what Apache is doing. If I rename scents.php to scents2.php and change my rules accordingly, it appears to be working. Anyone know how to disable this?

Edit:

HA! Multiviews! You go DIE NOW! :angry:

Edited by Pc_Madness
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.