Revenant
Revenant

Reputation: 2984

SEO URLs with htaccess conflict issues

I've got a small glitch with my .htaccess. I googled and tried few things without any result so I had to turn to SOF for help.

Consider following htaccess rule;

# CATEGORY LISTING
ReWriteRule ^listing/category/(.*)/(.*)/(.*)/(.*) ?module=listing&type=category&get=$1&c_id=$2&c_name=$3&page=$4 [L]

ReWriteRule ^listing/category/(.*)/(.*)/(.*) ?module=listing&type=category&get=$1&c_id=$2&c_name=$3 [L]

# CATEGORY FILTER
ReWriteRule ^listing/category/(.*)/(.*)/(.*) ?module=listing&type=category&orderType=$1&order=$2&page=$3 [L]

ReWriteRule ^listing/category(.*)/(.*) ?module=listing&type=category&orderType=$1&order=$2 [L]

ReWriteRule ^listing/category/(.*) ?module=listing&type=category&page=$1 [L]

ReWriteRule ^listing/category ?module=listing&type=category [L]

Problem here is with 2 rules are conflicting with each other;

This rule;

ReWriteRule ^listing/category/(.*)/(.*)/(.*) ?module=listing&type=category&get=$1&c_id=$2&c_name=$3 [L]

Conflicts with this rule;

ReWriteRule ^listing/category/(.*)/(.*)/(.*) ?module=listing&type=category&orderType=$1&order=$2&page=$3 [L]

Is there anyway to solve this conflict?

Thank you for your help.

Upvotes: 1

Views: 83

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

Is there anyway to solve this conflict?

To solve this, you need to make the URI for the get query string and order query string mutually exclusive. You have exactly the same regular expression for both of them, so the second one will never be applied because anything that would match the second one will simply be handled by the first one.

For example, you can make one of them look like: /order/category/(.*)/(.*)/(.*) and the other /listing/category/(.*)/(.*)/(.*). Those two URI's are mutually exclusive and will never conflict.

Additionally, you should change all of your (.*) to ([^/]*), because (.*) isn't greedy and will gobble up additional path.

Upvotes: 2

Related Questions