.htaccess - mod_rewrite issues with URL if page title has dashes -


i have page this:

http://www.url.com/folder/content.php?name=this-is-the-page-title&item_id=129 

as can see, title of page included in url, separated dashes.

so, i'd convert following mod_rewrite:

http://www.url.com/this-is-the-page-title-129.html 

for this, use mod_rewrite rule like:

rewriterule ^([^-]*)-([^-]*)\.html$ /folder/content.php?name=$1&item_id=$2 [l] 

unfortunately, using rule, 404 error. think problem because title separated dashes (-) , separator dash well, can't tell variables each other or that.

when change rule dash (-) slash (/) works fine:

rewriterule ^([^-]*)/([^-]*)\.html$ /folder/content.php?name=$1&item_id=$2 [l] 

but url becomes:

http://www.url.com/this-is-the-page-title/129.html 

...which don't want i'd have rewrite entire structure of page.

is there way working

http://www.url.com/this-is-the-page-title-129.html 

even page title being separated dashes?

thank :)

the problem is, specify ([^-]*) means matching sub-pattern should not contain dashes... page title might contain them.

so, instead, lets let first part anything slash:

rewriterule ^([^/]*)-([0-9]+)\.html$ /folder/content.php?name=$1&item_id=$2 [l] 

this way, before last dash go first sub-pattern, , digits after last dash - second one.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -