Psytherium
07-06-2007, 08:40 PM
I'm using an open source .NET URL rewriter to handing 301 permanent redirect and url rewriting on my site. We want to use the url rewrite to clean up our urls for SEO purposes, and we want to use the 301 redirect because we are changing up the directory structure for the URL paths. With the URL rewriter, we can use regular expressions in the web.config for both the redirecting and rewriting.
Well, our current naming convention makes it impossible to use a regular expression for the redirect. It's an apartment site, and for the ratings pages the url paths looks like this:
/ratings/texas.htm for the states pages
/ratings/tx-houston.htm for the cities pages
/ratings/tx-houston-apartmentname1234.htm for the apartment pages
We wants a structure something like this:
/ratings/Texas/ratings.htm
/ratings/TX/Houston/ratings.htm
/ratings/TX/Houston/Apartment-Name/ratings-1234.htm
The problem comes in when the city has a space in it: New York City, so the url is like this: /ratings/ny-new-york-city.htm. Well, then you have apartments with different length names like this: /ratings/ny-new-york-city-6th-avenue-lofts1234.htm.
So if I want to redirect /ratings/ny-new-york-city-6th-avenue-lofts1234.htm into /ratings/ny/new-york-city/6th-avenue-lofts/ratings-1234.htm or /ratings/tx-houston-spring-apartments1234.htm into /ratings/tx/houston/spring-apartments/ratings-1234.htm, there's no way for a regular expression to know when the city end and the apartment name beings.
Now, what I'm probably going to have to do is form all of the old page urls from the database and copy and paste them in as conditions in the web.config. So I'll have something like this:
<redirect url="/ratings/ny-new-york-city-6th-avenue-lofts1234.htm" to="/ratings/ny/new-york-city/6th-avenue-lofts/ratings-1234.htm" />
<redirect url="/ratings/tx-houston-spring-apartments1234.htm" to="/ratings/tx/houston/spring-apartments/ratings-1234.htm" />.
I'm not too opposed to this, except that I have over 100,000 pages that I would have to do this with. That would be a pretty loooong web.config. Would this slow my site down considerably? Is there ANY other way to handle this? Any advice would be great, thanks!
Well, our current naming convention makes it impossible to use a regular expression for the redirect. It's an apartment site, and for the ratings pages the url paths looks like this:
/ratings/texas.htm for the states pages
/ratings/tx-houston.htm for the cities pages
/ratings/tx-houston-apartmentname1234.htm for the apartment pages
We wants a structure something like this:
/ratings/Texas/ratings.htm
/ratings/TX/Houston/ratings.htm
/ratings/TX/Houston/Apartment-Name/ratings-1234.htm
The problem comes in when the city has a space in it: New York City, so the url is like this: /ratings/ny-new-york-city.htm. Well, then you have apartments with different length names like this: /ratings/ny-new-york-city-6th-avenue-lofts1234.htm.
So if I want to redirect /ratings/ny-new-york-city-6th-avenue-lofts1234.htm into /ratings/ny/new-york-city/6th-avenue-lofts/ratings-1234.htm or /ratings/tx-houston-spring-apartments1234.htm into /ratings/tx/houston/spring-apartments/ratings-1234.htm, there's no way for a regular expression to know when the city end and the apartment name beings.
Now, what I'm probably going to have to do is form all of the old page urls from the database and copy and paste them in as conditions in the web.config. So I'll have something like this:
<redirect url="/ratings/ny-new-york-city-6th-avenue-lofts1234.htm" to="/ratings/ny/new-york-city/6th-avenue-lofts/ratings-1234.htm" />
<redirect url="/ratings/tx-houston-spring-apartments1234.htm" to="/ratings/tx/houston/spring-apartments/ratings-1234.htm" />.
I'm not too opposed to this, except that I have over 100,000 pages that I would have to do this with. That would be a pretty loooong web.config. Would this slow my site down considerably? Is there ANY other way to handle this? Any advice would be great, thanks!