• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

Sign in to follow this  

.htaccess and Mod-rewrite

Recommended Posts

Pc_Madness    3

*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

Share this post


Link to post
Share on other sites
Mathachew    149

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?

Share this post


Link to post
Share on other sites
Pc_Madness    3
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?

Share this post


Link to post
Share on other sites
Mathachew    149

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.

Share this post


Link to post
Share on other sites
Pc_Madness    3
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.