Forum Moderators: phranque
different type of input:
aaa
aaa/
aaa/A1
aaa/A1/
aaa/yyy
aaa/yyy/A1
aaa/yyy/A1/
/aaa
/aaa/
/aaa/A1
/aaa/A1/
/aaa/yyy
/aaa/yyy/A1
/aaa/yyy/A1/
in all cases the part between starting / and /A1 or end must be selected.
aaa/yyy is the categorie path;
alle our products start with A1 (ie: A12345)
thus the selected part must be our categories:
aaa or aaa/yyy or even aaa/yyy/aaa/bbb
even with or without /A1-product at the end
I cannot get it.
^[/]?([A-Za-z0-9-/]*)[/]?[^A[0-9]]*
does not work.
RewriteCond %1 ^(([^/]+/)?[^/]+)/?$
RewriteRule ^([^A]+)(A1)? /script/categorie=%1 [L]
Or maybe just
RewriteRule ^([^/]+(/[^/A]+)?)(/A1)? http://www.example.com/script/categorie=%1 [L]
I not sure why you think there's the possibility that the leading slash may or may not be present. Either it will never be there, or it will always be there, depending on where this code is located.
Jim
this rule selects all categories like .../.../.../... (1 to many subcats) independent if there's a starting /
or if there's a product /A12345 at the end. and check the content in a text-map-file for matches.
(if use the tool 'Regex Coach' to check a syntax. Are you familiar with it? or do you use another one)
there always is a started / for rewrite conditions.
Well, what do you input? There's always a 'Wednesday' for rewrite conditions if I'd use
RewriteCond Wednesday ^ The part in question is the rule-pattern; anyway it looks like you're continuing in a new thread [webmasterworld.com].
And as you can see
(3) applying pattern '^/?([^A1]*)/$' to uri 'running/'
there always is a started / for rewrite conditions.
The RewriteRule pattern should either start with a slash or not start with a slash, depending on where the code is located, but the presence or absence of a leading slash is not going change between requests -- it will either always be there or it will always not be there, depending only on where this code is located.
Therefore, including the regular-expressions "?" quantifier after the slash is a waste of processing power, even if it's only a "little waste." The problem is that lots of little time-wasters add up to a big time-waster, and can force you into an early server upgrade. So, "neatness counts" and you should code to your exact requirements, and not include *anything* in your code that you do not fully understand...
Jim
It's almost like the ToolBar issue with the 404 yesterday, only possibly worse. I haven't been reading in here too much lately, but this is the second time in a day I've seen a left-side-of-the-rule pattern begin with /?.
I just figured it was a coding error earlier, but now I'm starting to think people are using 'generators' or something like the OP mentioned and it's generating 'put it anywhere' (httpd.conf ¦ .htaccess) code, because of 'simplicity' and 'works', never-mind anything else...
ADDED: It's the First Two Times I've seen a pattern begin with /? and I wondered why too. It makes a bit more sense now... Automation = 'Think for the user, rather than asking where the code will be used.'
Trying to work on the bluntness. :)
</extensionofmypreviouspost>
@BlueBlizz
not include *anything* in your code that you do not fully understand...
What jdMorgan said in bold x 2...
We're talking about stuff that breaks your site, can ruin your search engine rankings and can possibly break your server if you get it wrong, that's why it's a hidden file.
I recommend if you use any auto generation or tools, you compare it to your own knowledge. There's a bunch of tutorials and documentation in the Library [webmasterworld.com].