Jump to content


.htaccess Question accounting for a folder?

  • Please log in to reply
1 reply to this topic

#1 scm22ri

  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts

Posted 30 January 2013 - 05:09 PM

Hi Everyone,

How would I go about accounting for a folder in my .htaccess?

Meaning this is my domain



Should my htaccess code look like this?
RewriteRule ^/products/^([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L]

maybe this?
RewriteRule ^/products/([_a-zA-Z]+)/([^/]*)$ script.php?product=$1&inventory=$2 [L]

What am asking is this, how would I go about accounting for the actual folder that I want to put in-front of my URL?


#2 requinix

  • Administrators
  • Lazy Administrator
  • 9,142 posts
  • LocationWA

Posted 30 January 2013 - 06:59 PM

"Accounting for" isn't too descriptive but I think I know what you want.

^ applies to the very beginning of the entire URL (sans query string) being matched against. If you try the first one then it'll only match when the beginning of the string is somewhere in the middle of it. Which is impossible. Thus the second one is correct.

If you find that the Rule is not matching, try making the leading slash optional. Depending on where these Rules are and what else you may have with them, the slash might not be there.

Edited by requinix, 30 January 2013 - 06:59 PM.

The Reimann Zeta Function Trolley Problem | "Stop! You're spoiling my unjustified indignation!"

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users