URL with apostrophe won't rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

URL with apostrophe won't rewrite

Postby megan_taylor1 » Tue Aug 11, 2009 6:13 pm

The URL I'm using is:
http://domain.com/cute/Life's_a_Garden.html

And my rewrite rule is:
RewriteRule ^([A-Za-z_]+)/([A-Za-z_]+)\.html/$ details.php?cat=$1&des=$2 [L]

Obviously it's not catching and rewriting because there's an apostrophe in the second variable. However, when I change my rule to the following, it still does not catch the example above.

RewriteRule ^([A-Za-z_]+)/([A-Za-z_']+)\.html/$ details.php?cat=$1&des=$2 [L]

Any ideas anyone?
megan_taylor1
 
Posts: 14
Joined: Fri Nov 07, 2008 10:32 pm

Postby richardk » Wed Aug 12, 2009 11:12 am

What happens?

Try
Code: Select all
^([a-zA-Z_]+)/([^/]+)\.html/$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby megan_taylor1 » Wed Aug 12, 2009 3:02 pm

Hi RichardK,

I've rewritten the rule as you suggested to:
RewriteRule ^([a-zA-Z_]+)/([^/]+)\.html/$ details.php?cat=$1&des=$2 [L]

I still get the following error:
404 Not Found
The requested URL /cute/Life's_a_Garden.html was not found on this server.

I've tried with the single apostrophe and with %27.

Thanks for your help though!
megan_taylor1
 
Posts: 14
Joined: Fri Nov 07, 2008 10:32 pm

Postby richardk » Fri Aug 14, 2009 12:57 pm

You're rules match .html/ not .html. Do other URL match this rules? Try
Code: Select all
^([a-zA-Z_]+)/([^/]+)\.html$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 28 guests

cron