MOD REWRITE with a query title

New to mod_rewrite? This is a good place to start.

MOD REWRITE with a query title

Postby aizkolari » Thu Jul 09, 2009 4:15 pm

Hello,

I have passed days trying to do this, i need some help please.

my site has a dynamic structure in PHP with classified ending with an ID number, like this:

/links.php?action=show&link_id=38

in the php script there is a title called $sitenames but that is not present in the link above, how can i do to do something like this..?

/(here sitenames or title)/(here id number).htm

Thanks in advance to everybody.
aizkolari
 
Posts: 2
Joined: Thu Jul 09, 2009 4:06 pm

Postby richardk » Fri Jul 10, 2009 9:35 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^[^/]+/([0-9]+)\.htm$ /links.php?action=show&link_id=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby aizkolari » Fri Jul 10, 2009 12:24 pm

Thanks Richardk, that works fine.
but how can i fill spaces with hyphens (-) ???

Dan
aizkolari
 
Posts: 2
Joined: Thu Jul 09, 2009 4:06 pm

Postby richardk » Sun Jul 12, 2009 2:46 pm

You do that when you output the link with PHP. The mod_rewrite ignores the sitename/title.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 113 guests

cron