CSS reference during URL rewriting

Source: Internet
Author: User

Tonight, when I moved the last demo to the end of the setup, I found that CSS could not be referenced. I thought about it for more than half a day and found that it was a user. aspx is rewritten to user/user by me. when aspx occurs, the directory reference problem occurs. The solution is to add more When referencing CSS ".. /", after solving this problem, another problem is found. The validatacode is referenced on the page. aspx verification code page, because it conforms to the regular expression, so this is also rewritten (only after 10 minutes of study), although validatacode does not appear in the address bar ., but it is overwritten. it also proves one thing. during rewriting, the address in the address bar is not only overwritten, but also the URL referenced in the URL is rewritten (of course, the regular expression is simply written "*\. in the case of aspx "), if there is no frame page in the page to reference another page or the page is very small, you can use the IF (* = validatacode) Return method without rewriting, of course, * the content can be obtained only by writing a few codes. The specific solution is to modify the regular expression as needed!
The final code in my configuration is as follows:
String suffixurl, lasturl, newurl = string. Empty, userid = string. empty;
Lasturl = request. rawurl;
If (lasturl. substring (0, 8). tolower () = "/cqspace") // deletes the root directory name
{
Suffixurl = lasturl. substring (9). tolower ();
}
Else
{
Suffixurl = lasturl. substring (1). tolower ();
}
If (suffixurl. tolower () = "default. aspx ")
{
Return;
}
Else
{
RegEx myreg = new RegEx (@ "(^ \ W + \ D *) \. aspx $ ");
If (myreg. ismatch (suffixurl ))
{
If (suffixurl. lastindexof ('/')>-1) return; // when a level-2 directory exists
Int lenght = suffixurl. lastindexof ('.');
Userid = suffixurl. substring (0, lenght );
If (userid. tolower () = "validatecode") return; // Verification Code
Newurl = "~ /User. aspx? Userid = "+ userid;
Httpcontext. Current. rewritepath (newurl );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.