Jump to content

[SOLVED] Question about RewriteCond


therealwesfoster

Recommended Posts

Here's the code:

 

### Cond: Has cat set (subdomain). Contains online/viewing
RewriteCond %{HTTP_HOST} ^([^\.]+)\.site\.net$ [NC]      # Extract the subdomain part of site.net
RewriteCond %1 !^(www|ftp|mail)$ [NC]                    # Check that the subdomain part is not www, ftp or mail
RewriteCond %{REQUEST_URI} (online)\/(viewing) [NC]      # Contains ONLINE/VIEWING

# Cat
RewriteRule ^online/viewing/([\w-]+)$                    ./$1.php?cat=%1 [NC,L,QSA]

 

Here is my question. Why is it that the Condition vars (%) are like so:

%0 = online/viewing

%1 = online

%2 = viewing

 

Shouldn't %1 be the category, %2 be "online" etc.? Why is the first RewriteCond not saved in the %variables?

 

Note: I have solved this myself (before posting this topic) by just switching the 2 RewriteConds around (which allows %1 to be the category). My question isn't "how do I fix this?", it is simply "why does %1 not equal the category?"

 

Thanks!

 

Wes

Link to comment
https://forums.phpfreaks.com/topic/135597-solved-question-about-rewritecond/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.