Forum Moderators: phranque

Message Too Old, No Replies

Simple mod_rewrite question

So simple I can't figure it out

         

madmatt69

9:10 pm on Feb 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey everyone,

New to mod_rewrite and have only been able to find tutorials online for complicated re-write rules like rewriting dynamic urls to static, etc.

I have a simple one.

I want to just change a few affiliate links so that instead of showing "domain.com/aff/123" to "domain.com".

Nothing dynamic about the urls.

Is there a way to do this?

Thanks for any info. I did a site search but again it seemed that most posts delt with more complicated used of mod_rewrite than what I'm looking for.

jdMorgan

5:26 am on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The purpose of mod_rewrite is to rewrite incoming URLs to a filename not derived directly from that URL (rewriting), or to rewrite incoming URLs to a different URL (redirectng). mod_rewrite supports both of those functions, and some variants such as making proxy requests as well.

So, your question involves two parts; Change (in your case, manually) the URLs on your pages to something different from what is there now, and then use mod_rewrite to change those URLs back to the correct path needed to handel the next page requested by clicking that link. If these new links on your pages lead to another site, then mod_rewrite can't help, because your mod_rewrite code only runs on your server.

Jim

madmatt69

5:35 am on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the response Jim.

The reason I'm asking is because I recently came across a site that had a link written to a .zip file, "example.zip" which upon clicking would take you to an affiliate website.

I'm not looking to fake zip files, but rather just hide the affiliate link.

Could I do something like mod_rewrite a link to look like "www.mysite.com/productname" and then upon clicking it would take you to "www.affiliatesite.com"?

jdMorgan

6:29 am on Feb 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, certainly. Each "zip" link will need to be unique so that it can be translated to one of your aff links. If you can come up with a systematic approach, it may be possible to redirect more than one link with each rule -- this depends on how similar the real and redirected links are to the others of their type.

This has the effect of putting a redirect between the link on your site and the page on your affiliate's site. Search engines will follow that link, and may index the target URL as well, so I'm not sure what this really accomplishes except to diguise the target from people who check the status bar while hovering on your link. If that's all you need to do, then it should work OK.

Jim