Two the same rules

Discuss practical ways rearrange URLs using mod_rewrite.

Two the same rules

Postby Gaudino » Thu Oct 09, 2008 7:04 am

Hi, I have only one very important question, because I dont know how can I make it.

How can I make distinction between:

index.php?strana=jednopolozkova&menu=something1

and

index.php?strana=vicepolozkova&menu=something2

I have this, because its not good:
RewriteCond %{QUERY_STRING} ^strana=jednopolozkova&menu=([^&]+)$
RewriteRule ^index.php$ %1/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ ?strana=jednopolozkova&menu=$1 [L,QSA]

RewriteCond %{QUERY_STRING} ^strana=vicepolozkova&menu=([^&]+)$
RewriteRule ^index.php$ %1/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ ?strana=vicepolozkova&menu=$1 [L,QSA]
Gaudino
 
Posts: 1
Joined: Thu Oct 09, 2008 6:16 am

Postby richardk » Thu Oct 09, 2008 11:39 am

You have to add something to the URLs to make them different. For example /jedno/something1/ and /vice/something2/.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?strana=(jedno|vice)polozkova(&.*)?$ [NC]
RewriteCond %1&%{QUERY_STRING} ^(jedno|vice)&(.*&)?menu=([^&]+)(&.*)?$ [NC]
RewriteRule ^index\.php$ /%1/%2/? [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(jedno|vice)/([^/]+)/?$ /index.php?strana=$1polozkova&menu=$2 [QSA,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 8 guests

cron