Basic expression

Discuss practical ways rearrange URLs using mod_rewrite.

Basic expression

Postby jorkam » Wed Jul 30, 2008 7:30 am

I have these friendly URl

http://www.domain.com/testestes-40.html

And I need to get ID 40, that's the IDcategori for a seccion.

I don't have success with:

RewriteRule ^([a-z]+).*([1-9]+)\.html$ /index.php?id_cat=$1 [L]

and :o

RewriteRule .*([1-9]+)\.html$ /index.php?id_cat=$1 [L]

Any answer plz?

Thnk !!!
jorkam
 
Posts: 7
Joined: Wed Jul 30, 2008 7:25 am

Postby richardk » Wed Jul 30, 2008 4:15 pm

1-9 does not include 0.

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^[^/]+-([0-9]+)\.html$ /index.php?id_cat=$1 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jorkam » Wed Jul 30, 2008 11:43 pm

Thnk so much Richardk

It’s OK!!!

Yesterday I spent all day and I only got wrong solutions: :evil:
RewriteRule .*/-([0-9]+)\.html$ /index.php?id_cat=$1 [L]

Yours it’s perfect.

About it, in the site I have a folder for each language like these:

/en/a-category-subcategory-6.html
/es/a-category-subcategory-15.html

I dream with something like these but without results “Wrong”:
RewriteRule ^([(en|es)])+-([0-9]+)\.html$ /index.php?id_cat=$1&language=$2 [L]


The only is making each individuals:
RewriteRule ^es/.*-([0-9]+)\.html$ /index.php?id_cat=$1&language=es [L]

RewriteRule ^en/.*-([0-9]+)\.html$ /index.php?id_cat=$1&idioma=en [L]


Any can suggest alternatives?
Last edited by jorkam on Thu Jul 31, 2008 1:00 am, edited 2 times in total.
jorkam
 
Posts: 7
Joined: Wed Jul 30, 2008 7:25 am

Postby richardk » Fri Aug 01, 2008 3:45 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(en|es)/[^/]+-([0-9]+)\.html$ /index.php?language=$1&id_cat=$2 [L]
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 46 guests

cron