0

Hi, I'm having a problem with what seems to be conflicting URL rewrite rules. Basically the first and second rule work individually but when i add both together the second rewrite rule no longer works.

RewriteEngine On 
RewriteBase /
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 


RewriteRule ^(.*)$ site/index.php?content=$1 [L] [NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /site/index.php?content=$1&pageNum_gproducts=$2&totalRows_gproducts=$3 [L]

I am not great with mod rewrite so any help is much appreciated

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Thanks for the quick reply, i did try that but for some reason it seems to break the link to the css page. I use root relative links but even if i use the full url it does not seem to load.

However, if i take the second rule out so its like this they load no problem. Any ideas?

RewriteEngine On
    RewriteBase /
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /site/index.php?content=$1&pageNum_gproducts=$2&totalRows_gproducts=$3 [L]
0

I have also just checked the admin system and it also seems to be getting redirected now. If i go to /admin/login.php the index page is loaded without any css.

So, it seems like the rule is being matched while disregarding that this is an actual file.

0

Am not entirely sure whether the rewritecond acts like an 'or', ignoring the second and third if the first evaluates to true.

0

The second and third variable will always be a number for purposes of the rule so I thought something like this would work but it does not. I'm not sure if the rule is correct but i was hoping that this would cause the rule to fail if it was a directory/file as they would never be only a number.

RewriteRule ^([^/]*)/([0-9]+)/([0-9]+)$ /site/index.php?content=$1&pageNum_gproducts=$2&totalRows_gproducts=$3 [L]
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.