Why doenst this work?

Discuss practical ways rearrange URLs using mod_rewrite.

Why doenst this work?

Postby azplund » Mon May 25, 2009 2:54 am

Hi!


Just wonder how to do a rule for this:

I have a page like this:
index.php?s=$1&$2&page=$3

For example it can be:
index.php?s=sp&alla&page=1

where

$1 represent the "main page" wich is sp
$2 represent wich type of genre it is (any form om $_GET)
$3 represents wich page it is in the pagination function..


I just wonder how to do so the link (index.php?s=$1&$2&page=$3) can be ruled so the visible linkpath(the friendly URL) will look something like this:

www.mypage.com/spel/<genre here>/<pagenumber here>.html


The rest of my rules looks like this:
Code: Select all
RewriteEngine On

# /azplund --> /index.php?s=medlem&v=azplund
RewriteRule ^([a-z_][-a-z_]+)$                  /index.php?s=medlem&v=$1         [NC,QSA,L]

# /azplund/fotoalbum --> /index.php?s=medlem&v=azplund&show=nagonsida
RewriteRule ^([a-z_][-a-z_]+)/([a-z_][-a-z_]+)$ /index.php?s=medlem&v=$1&show=$2 [NC,QSA,L]

# /azplund/fotoalbum --> /index.php?s=medlem&v=azplund&show=nagonsida&album=visanågotalbum
RewriteRule ^([a-z_][-a-z_]+)/([a-z_][-a-z_]+)/([a-z_0-9][-a-z_0-9]+)$ /index.php?s=medlem&v=$1&show=$2&album=$3 [NC,QSA,L]

# /nagon_typ_av_sida/ --> /index.php?s=nagon_typ_av_sida
RewriteRule ^([A-Za-z0-9\_][A-Za-z0-9\_\-]+)(/)?$ index.php?s=$1 [NC,QSA,L]


# <---------------    THIS IS THE ONE I WANT TO REPLACE ------------->
#/spel_eller_filmer/genre/sida --> /index.php?s=filmer&alla&page=nagon_sida
RewriteRule ^([a-zA-Z\_]+)/([a-zA-Z\_]+)/([0-9]+) index.php?s=$1&$2&page=$3 [NC,QSA,L]
# <---------------   // THIS IS THE ONE I WANT TO REPLACE ------------->


# /spela/spelet.html --> /index.php?s=spela&spelet=nagot_namn_pa_spelet
RewriteRule ^spela/(.+)\.html$ /index.php?s=spela&spelet=$1 [NC,QSA,L]

# /fullskarm/spelet.html --> /fullskarm.php?spelet=nagot_namn_pa_spelet
RewriteRule ^fullskarm/(.+)\.html$ /fullskarm.php?spelet=$1 [NC,QSA,L]

# /film/filmens_namn.html --> /index.php?s=visa_film&film=namnet_pa_filmen_komer_har
RewriteRule ^film/(.+)\.html$ /index.php?s=visa_film&film=$1 [NC,QSA,L]


Is it possible to do this at all?

Nice day!

/azplund
Last edited by azplund on Tue Jun 02, 2009 7:14 am, edited 1 time in total.
azplund
 
Posts: 4
Joined: Wed May 20, 2009 9:35 am
Location: Sweden

Postby richardk » Fri May 29, 2009 8:54 am

What happens when you go to /sp/alla/1.html?

Try
Code: Select all
RewriteRule ^([a-z_]+)/([a-z_]+)/([0-9]+)\.html$ /index.php?s=$1&$2&page=$3 [NC,QSA,L]

at the beginning of your mod_rewrite file instead of in the middle.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby azplund » Tue Jun 02, 2009 7:17 am

richardk wrote:What happens when you go to /sp/alla/1.html?

Try
Code: Select all
RewriteRule ^([a-z_]+)/([a-z_]+)/([0-9]+)\.html$ /index.php?s=$1&$2&page=$3 [NC,QSA,L]

at the beginning of your mod_rewrite file instead of in the middle.



oh sweet mother of...

Da*n! Worked perfect!
Finally the site is up again. There has been a message "This user bla bla limited blabla" Great answer and prefect that the site is up!

Nice!
azplund
 
Posts: 4
Joined: Wed May 20, 2009 9:35 am
Location: Sweden


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 13 guests

cron