July 06, 2020, 04:43:25 pm
News: If someone gives you crap then give them a Bad Star
Pages: [1]   Go Down
Author Topic: Redirect by url on a window server (i wish i could use .htaccess)  (Read 4221 times)
simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8551



« on: November 02, 2010, 06:27:48 pm »

Lets say I have a page:
www.sitename.com/page.asp?id=1234

That id is a users id in the database, pulls up custom data from the database.

What I would like to do is have something like:
www.sitename.com/username



One Idea I have is using www.sitename.com/username.html with a javasript redirect, but is there a cleaner way?
Logged

                 ..... .....

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4536


Pure Evil Administrator


WWW
« Reply #1 on: November 02, 2010, 07:30:55 pm »

Hmm. Yeah I know the problem you have. Now I have an idea how to do this in ASP but in PHP I can access the URL completely and can break it down so that it would be www.sitename.com/users/myusername then I know that users. If there's an ASP equivalent to the $_SERVER global variable array then you might be able to pull it off too.
Logged

-- signature --

simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8551



« Reply #2 on: November 02, 2010, 08:03:29 pm »

If I understand the variable you are referring to, it would be similar to Server variables.

The issue would be one of "where to do this" since www.sitename.com/username just provides a 404 Another Tounge
Logged

                 ..... .....

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4536


Pure Evil Administrator


WWW
« Reply #3 on: November 02, 2010, 09:05:47 pm »

Yeah you would still need some sort of way to get to the index.

I know of some Rapid Development Frameworks that have what you want as an option without the use of the ReWrite in the .htaccess. I just can't remember how they do it.

Code Ignite is one as well as WordPress. Maybe you should take a look at their PHP code and that might give you an idea on how to do that with ASP.
Logged

-- signature --

wrack
Master of TMEOotAP
*

Stars: +3/-0
Offline Offline

Posts: 11116


Don't look back. Look in the mirror to look back.


WWW
« Reply #4 on: November 03, 2010, 05:10:37 am »

With ASP.NET this is really easy. Check few examples and stuff.

http://msdn.microsoft.com/en-us/library/ms972974.aspx
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/

With IIS7 and ASP.NET 3.5 it's even easier.

http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
Logged

simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8551



« Reply #5 on: November 03, 2010, 02:32:38 pm »

Good to know, will save those for if I have the same issue when using .net. Saddly, Ive been working in asp classic, and have no access to the iis.

The client said that they are cool with the url ending in .asp so I'll just create pages like www.sitename.com/username.asp (in code of course) that take the page name and turn that into userid & redirect.

Logged

                 ..... .....

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4536


Pure Evil Administrator


WWW
« Reply #6 on: November 03, 2010, 03:15:13 pm »

Yeah that makes sense. The whole idea is to get away from the standard query string with ? or other odd characters in the URL. Mostly because search engines don't like (or didn't like it, not sure how things are now).
Logged

-- signature --

simmo
Administrator
*

Stars: +3/-0
Offline Offline

Gender: Male
Posts: 8551



« Reply #7 on: November 03, 2010, 03:39:18 pm »

Yup, I have used .htaccess for a client in the past, teh url was the item name (was a store site) but it translated to a long url w/id #s and whatnot. That was specifically for SEO purposes.


In this case it is more for human benefit though, is an auction site, and we want an easy way for users to get to "store fronts." this way they can type store name rather than page.asp?id=1234
Logged

                 ..... .....

Pages: [1]   Go Up
Print
 
Jump to: