Regex Pattern Matching bug in my rewrite
5 posts
• Page 1 of 1
Regex Pattern Matching bug in my rewrite
Hey Guys,
Please help, I'm tipping this issue is due to my intermediate understanding of regex ( I usually get by fine ).
I have the following rule in my .htaccess
RewriteCond %{HTTP_HOST} ^([edith\.|bertha\.]*)([visual|performing|screen|architecture|design|publishing]+)\.sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
This examples works fine:
edith.performing.sitename.com it does an internal redirect to the page 'section-performing.aspx?SectionId=x'
edith.visual.sitename.com it does an internal redirect to the page 'section-visual.aspx?SectionId=x'
edith.publishing.sitename.com it does an internal redirect to the page 'section-publishing.aspx?SectionId=x'
However If I go to 'architecture'
edith.architecture.sitename.com it writes to 'section-rchitecture.aspx?SectionId=x' (The 'a' in architecture is dropped??)
If I go to 'design'
edith.design.sitename.com it writes to 'section-sign.aspx?SectionId=x' (The 'de' in design is dropped??)
Can anyone tell me where my stupidity lies...
Errol (^_^)
Please help, I'm tipping this issue is due to my intermediate understanding of regex ( I usually get by fine ).
I have the following rule in my .htaccess
RewriteCond %{HTTP_HOST} ^([edith\.|bertha\.]*)([visual|performing|screen|architecture|design|publishing]+)\.sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
This examples works fine:
edith.performing.sitename.com it does an internal redirect to the page 'section-performing.aspx?SectionId=x'
edith.visual.sitename.com it does an internal redirect to the page 'section-visual.aspx?SectionId=x'
edith.publishing.sitename.com it does an internal redirect to the page 'section-publishing.aspx?SectionId=x'
However If I go to 'architecture'
edith.architecture.sitename.com it writes to 'section-rchitecture.aspx?SectionId=x' (The 'a' in architecture is dropped??)
If I go to 'design'
edith.design.sitename.com it writes to 'section-sign.aspx?SectionId=x' (The 'de' in design is dropped??)
Can anyone tell me where my stupidity lies...
Errol (^_^)
Re: Regex Pattern Matching bug in my rewrite
I'm tipping however that is has something to do with 'edith' containing 'de' which is then negated in my rewrite rule for 'design'
And 'bertha' containing 'a' which is then negated in my rewrite rule for 'architecture'
Am I close???
And 'bertha' containing 'a' which is then negated in my rewrite rule for 'architecture'
Am I close???
Re: Regex Pattern Matching bug in my rewrite
Haha, I've fixed my own problem, realising my error...
I removed the [] which makes the words literals (Doh)
The rule is now
RewriteCond %{HTTP_HOST} ^(edith\.|bertha\.)*(visual|performing|screen|architecture|design|publishing)+\.sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
I hope this helps someone else that has made the same mistake.
Errol (^_^)
I removed the [] which makes the words literals (Doh)
The rule is now
RewriteCond %{HTTP_HOST} ^(edith\.|bertha\.)*(visual|performing|screen|architecture|design|publishing)+\.sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
I hope this helps someone else that has made the same mistake.
Errol (^_^)
- syedshah20
-
- Posts: 1
- Joined: 19 Dec 2014, 03:24
Re: Regex Pattern Matching bug in my rewrite
Thanks this helps.
These examples are for the entire site, but how can I apply these rules to a single web page?
These examples are for the entire site, but how can I apply these rules to a single web page?
Re: Regex Pattern Matching bug in my rewrite
If you wanted to apply this to a single page, you would mention the page in the RewriteRule
If the page was 'shop/televisions/my-television.html'
RewriteCond %{HTTP_HOST} ^(edith\.|bertha\.)*(visual|performing|screen|architecture|design|publishing)+\.sitename(.+)/? [NC]
RewriteRule ^shop/televisions/my-television\.html$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
Errol![Smile :)](./images/smilies/icon_e_smile.gif)
If the page was 'shop/televisions/my-television.html'
RewriteCond %{HTTP_HOST} ^(edith\.|bertha\.)*(visual|performing|screen|architecture|design|publishing)+\.sitename(.+)/? [NC]
RewriteRule ^shop/televisions/my-television\.html$ /${mapfile_domains:%3}/section-%2.aspx?SectionId=${mapfile_sections:%2} [L]
Errol
![Smile :)](./images/smilies/icon_e_smile.gif)
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 11 guests