apache rewrite not working as expected -


i trying rewrite url variables php,

so far, have:

rewriteengine on rewriterule ^sub/(.*).html$ index.php?sub=$1 rewriterule ^(.*).html$ index.php?page=$1 

the /sub/ 1 working fine, although page 1 not working,

sorry, beginner @ rewrite rules,

can shed light? guessing issue cant stack rewrite rules have...

i can not alter directory structure in way, have work with:

page.html page2.html sub/123.html sub/827.html 

thanks in advanced!

~jmyeom

edit

adding [nc,l] @ end of rules resolves issue,

i.e

rewriteengine on rewriterule ^sub/(.*).html$ index.php?sub=$1 [nc,l] rewriterule ^(.*).html$ index.php?page=$1 [nc,l] 

although, now, how make did not rewrite on different subfolder not /sub/, i.e, /src/?

thanks again ~jmyeom

if understand last question (after edit), want limit second rewrite rewrite pages, not rewrite other subdirectories?

you can changing text that's matched "any character except /":

rewriterule ^([^/]*)\.html$ index.php?page=$1 [nc,l] 

in regular expressions, [ ] matches specified character, , if put ^ @ start, matches character doesn't come between square brackets... here we're matching isn't slash.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -