PDA

View Full Version : mod_rewrite part 2



mobilebadboy
04-29-2004, 01:23 AM
Ok, I've been giving myself a headache for the last couple of hours, and finally surrendered.

I've got this line of my htaccess working:

RewriteRule /([^./]+)/?$ /product.php?ASIN=$1

When I add the following line, it works:

RewriteRule /([^./]+)/?$ /olympus_cameras.php?Browse=493672&Sort=Sales&Page=$1

But the first one quits working. It rewrites the URL, but it just refreshes the current page.

Depending on where I move the 2nd line one or the other works. Say if I move the olympus line to the top, it quits working and then the product line works.

And depending on how I change the olympus line, it often just gives me a blank white page with "No results found" and the return to the previous page link. But the product line works.

I'm beginning to not like mod_rewrite. :rolleyes:

Chris
04-29-2004, 03:37 PM
I could recommend a non mod_rewrite solution.

mobilebadboy
04-29-2004, 04:03 PM
Thanks, but after racking my brain for a few hours, and getting all but the one link to work, I'd realy to like to succeed with the mod_rewrite version. :) I can't let it beat me. And the rest of the site is running off rewrite, except for the pagination at the bottoms of the pages.

pas
04-29-2004, 05:56 PM
Try using the last [L] directive:

RewriteRule /([^./]+)/?$ /product.php?ASIN=$1 [L}
RewriteRule /([^./]+)/?$ /olympus_cameras.php?Browse=493672&Sort=Sales&Page=$1 [L}

pas
04-29-2004, 05:57 PM
Actually, you're probably going to need to specify more specifically matching regexps than "/([^./]+)/?$".

mobilebadboy
04-29-2004, 07:08 PM
Ok, I'm close. Everything is working...just not quite like I want though. Here's what I have:

RewriteRule /([0-9]+)/?$ olympus_cameras\.php?Browse=493672&Sort=Sales&Page=$1 [L]
RewriteRule /([^./]+)/?$ /product.php?ASIN=$1 [L]

But, if you go to /olympus-cameras/2, then the URL looks like I want when you click on a product: /olympus-cameras/B0001DKQWI/.

But if you go to /olympus-cameras/2/, then the URL looks like: /olympus-cameras/2/B0001DKQWI/.

Which is good in a way, both /2/ and /2 work. I've tried messing around with it, but I'm scared to since I finally got it working for the most part. :o When I do, then only one or the other works.

mirdin
05-16-2004, 01:46 AM
I could recommend a non mod_rewrite solution.

Would you mind sharing how you create the short url's in your aws sites?

Does Google prefer shorter url's over longer url's ?

Mike
05-16-2004, 01:53 AM
http://www.websitepublisher.net/article/search_engine_friendly_urls :)

chromate
05-16-2004, 02:41 AM
Shorter URLs seem to get crawled faster.

mirdin
05-20-2004, 12:36 AM
http://www.websitepublisher.net/article/search_engine_friendly_urls :)

Don't see any mod_rewrite rules posted there though :)
I'd rather stick to mod_rewrite.

ASP-Hosting.ca
05-20-2004, 05:54 AM
I could recommend a non mod_rewrite solution.

Chris,

What's wrong with mod_rewrite?

Mike
05-20-2004, 08:36 AM
Don't see any mod_rewrite rules posted there though :)
I'd rather stick to mod_rewrite.
Yeah, but that's how Chris uses his short urls i think.