Using { ASP.NET 3.5 , Windows Server 2003 , IIS 6 }
I'd like to optimize my site for SEO. For the sake of example, I have a site with three pages:
- /news.aspx - a page that lists news articles
- /events.aspx - a page that lists events
- /location.aspx - a page that determines user's geographic location
If user visits /news.aspx or /events.aspx without going to /location.aspx first, he sees unfiltered content (all news articles or all events). To narrow that down, the user goes to /location.aspx. The location page lists states that the user can click. When user clicks a state, he gets a list of cities. When user clicks a city, he get a list of streets. When 开发者_运维百科user clicks a street, he is taken back to /news.aspx, but the content he sees is now filtered by location. Same thing goes if the user clicks on the /events.aspx page.
I can do all this through session or cookies, but, for SEO, I have search bots to contend with. I'm pretty sure URL re-writing is the way to go, but the examples I'm finding (and they are a-plenty) deal with simple stuff like /products/umbrellas or /books/authors/spolsky. It -feels- more complicated than that (maybe it's more simple... set me straight).
My initial thought is that I need some form of URL rewriting handler or module so that I can begin using urls like mysite.net/WA/Seattle/Pike_Pl. Then, once the location is determined, all the internal urls in the site would have the location in them... to get to /events.aspx, the link would actually point to mysite.net/WA/Seattle/Pike_Pl/events.aspx. The handler would get the location information out of the url path and rewrite the url to /events.aspx?state=WA&city=Seattle&street=Pike_Pl. The same would go for /news.aspx or any other location sensitive page in my site.
If you've done something similar, code examples would be appreciated.
Byron
Wouldn't it be easier to just create a control that can be placed on all of the mentioned pages, allowing for "in-place" filtering?
Then the matter of the url rewriting. I would have the urls look like the following:
- http://siteurl.com/events/AREA/CITY/STREET
- http://siteurl.com/news/AREA/CITY/STREET
Both the events and news page would have the control "SetLocation.ascx" on it. Now there is no need to first visit the location.aspx page, use the control to get these settings.
THen use any of the available open source UrlReWriters available to catch urls like http://siteurl.com/events/AREA/CITY/STREET and http://siteurl.com/news/AREA/CITY/STREET and have them be mapped to an internal url with regular expressions (which most if not all urlrewriters use) like so:
<rewrite url="~/Events/(.+)" to="~/Event.aspx?area=$1" />
<rewrite url="~/Events/(.+)/(.+)" to="~/Event.aspx?area=$1&city=$2" />
<rewrite url="~/Events/(.+)/(.+)/(.+)" to="~/Event.aspx?area=$1&city=$2&street=$3" />
Then use an url like http://siteurl.com/event/EVENTNAME to point to an actual event (note the missing 's' after /event in the url). Save the currently selected area/city/street in the session and update it when the user changes it using the SetLocation.ascx control.
精彩评论