2
votes

I have look all over the web and can't seem to figure this one out. I am using the Tuckey rewrite engine. I have read the manual and reviewed the examples without help.

I want to remove ".html" extensions from the URL, while preserving parameters if there are any.

Here is what I have thus far (non-working):

<rule>
    <note>Example: http://hostname/sample/loginhelp?cid=2 is masked from http://hostname/sample/loginhelp.html?cid=2</note>
    <from>^(.*)\?(.*)$</from> 
    <to>$1.html?$2</to>
</rule>
<outbound-rule>
    <note>Example: http://hostname/sample/loginhelp.html?cid=2 is redirected to http://hostname/sample/loginhelp?cid=2</note>
    <from>^(.*)(\.html)(.*)$</from>
    <to type="redirect">$1$2</to>
</outbound-rule>

Neither the rule or outbound-rule seem to work in any scenario. I know the Tuckey is working since I can get other rules to work, just not this one. Also, I am using the Seam stack although I don't think it matters. What am I missing?

1

1 Answers

0
votes

Use the wildcard matching engine to simplify this:

<rule match-type="wildcard">
    <from>*.html?*</from>
    <to>$1?$2</to>
</rule>