Forum Moderators: phranque

Message Too Old, No Replies

Rewrite .asp

         

MarcyBoy

10:39 am on Jun 27, 2012 (gmt 0)

10+ Year Member



I need to rewrite the following. I have searched for a solution and tried loads of examples but can't get it to work.

www.example.com/display.asp?k=12345678910

to

www.example.com/catalogsearch/result/?q=12345678910

where the number 12345678910 changes for different products.

Can anyone show me how to do this please?

g1smd

12:26 pm on Jun 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What have you tried?

A rewrite connects a URL request to an internal filepath.
Which one of the above is the new URL and which one is the internal filepath?

The URL will include a hostname.
The filepath will not.


[webmasterworld.com...] discusses some rewriting terminology.

MarcyBoy

12:32 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



The bottom url is the one I want to end up with. The host is the name in both cases. We have rebuilt the site and want to connect the old links. The first URL is the old link structure.

g1smd

12:44 pm on Jun 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So you have changed the names of the files inside the server and changed the URLs you use to access the content and want to redirect people asking for the old URL to now ask for the new URL.
Is that it? If so, you need a redirect not a rewrite.

The alternative is that you have changed the name of the file inside the server and want to continue using the old URL to access the content. In that case you do need a rewrite; one that connects requests for the old URL to the new internal filepath.
Although they use similar syntax , redirects and rewrites are two quite different things.

MarcyBoy

12:50 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



your first senario is correct. The site has been changed from using .asp files to .php files.

Are you able to give an example of the redirect line(s) I need?

g1smd

12:56 pm on Jun 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In two lines of code you could have continued using the old URLs to access the content. Google would never know you had changed the technology inside the server. URLs are used "out there" on the web. Filepaths are used "here" inside the server. They are not at all the same thing, merely related by the actions of the server configuration.

I would urge you to take the opportunity to swap to extensionless URLs and redirect .asp and .php requests to those. There's several threads in the last week and many more in the last few years about that here.

MarcyBoy

1:06 pm on Jun 27, 2012 (gmt 0)

10+ Year Member



I've already done that. I particularly need this redirect as it redirects old product URL's to the new structure search url. The number is in fact a book ISBN number.

The new structure uses seo friendly URLs which can't be automatically matched to the ISBN number form the old URLs

g1smd

7:09 pm on Jun 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What code have you tried so far?

There's approximately 40 000 threads with examples of different types of redirect here.