Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL Rewrites

Status
Not open for further replies.

Totenkopf

Technical User
Jun 15, 2006
4
CA
Hello,

I am working on a business directory website where users can create a business listing page which can be visited using a custom path they specify. For example, if they create a listing with a path named "myCompany", people can visit their page using rather than something like
I've read through some of this material so I have a basic understanding of how Application_BeginRequest and Context.RewritePath works, however for my described situation, it seems to me this requires a folder be created on our webserver with an asp index page within every time a user signs up. For example, there will be a "myCompany" folder with an index.aspx page under our root, so when a user goes the Application_BeginRequest can process that page and Context.RewritePath to the appropriate query page. Am I doing this right or is there a better way that doesn't require subdirectories to be created on our webserver?

Also, regarding Context.RewritePath, when it forwards to the appropriate query string page, the content seems to be there, but the CSS presentation of the site gets messed up. What could be causing this?



Thanks for any help !
 
interesting concept,
just a thought...

can you do a then do the redirect off of that? A dns entry of *.mysite.com should allow that to be somewhat dynamic.

or can you do and the index.aspx of site.com would do the redirect after checking for that querystring.

im sure anythings possible, and a dynamic subdirectory would be nifty, can't wait to see where this goes.
 
it seems to me this requires a folder be created on our webserver with an asp index page within every time a user signs up
I'm pretty sure that isn't the case. You can intercept any request made to the server and direct it accordingly however, I think it is a setting in IIS that will have to be modified so that ASP.NET is the default handler for all requests (i.e. by default it will handle .aspx extensions but it needs to be told to handle all other requests as well).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Have you ever thought about using SharePoint for something like this? I know that doesn't answer your question, but it might be worth looking into.
 
Hi, this is something we do quite a lot of as we do WAP sites so try to keep the lengths of URLs down. It's pretty quick to setup, however the following does depend on you being able to set custom errors in IIS. To do this we have a URL that looks similar to:
The directory mycompany doesn't actually exist though,
We then set a custom 404 page in IIS... right click on the website, Properties, Custom Errors tab, scroll to 404, edit it, setting the type to URL and the path as /listings.aspx (assuming it's in th eroot)

Then, in your listings.aspx page, you need to use:

Request.Url.AbsoluteUri

This will return something like:
I can't remember the exact string, but it's similar to that. So you can just look for the last '/' and read to the right of it to get your site name. You can do a redirect or whatever you want as you now have mycompany available in listings.aspx.

Hope that works out for you. Let me know how you get on.

Rob
 
No. You shouldn't ever need to set up sub-directories to implement URL rewriting. Something is wrong.

This is everything you need to know about the process of URL rewriting if you haven't stumbled upon the resource already:


Also, to save yourself the hassle of debugging, you may just want to opt for a pre-made solution like this:


As far as the CSS goes, if it's messed up, make sure that the path is correct (try to make it root relative or absolute). In other words, make sure you're not referencing the file like "myStyles.css" vs. "/myStyles.css" because the browser will be looking for a file that doesn't exist given your URL (" vs. "
Also, make sure that that your URL rewriter isn't rewriting the path to your CSS file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top