Mod Rewrite: script/var1/var2/var3 [three different files]

Hello,

I have following files:
script1.php
script2.php
script3.php

script1.php?s=ss&c=cc&p=all
=
/script1/ss/cc/all

script2.php?s=ss&c=cc&d=dd&p=all
=
/script2/ss/cc/dd/all

script3.php?s=ss&c=cc&d=dd&cg=gg&p=all
=
/script3/ss/cc/dd/gg/all

Please, could somebody suggest me a Mod_Rewrite file for that?

Thank you in advance!
Adam
Aidam-UnlimitedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Avinash ZalaWeb ExpertCommented:
Try below rules i your .htaccess file

RewriteRule ^script1/ss/cc/all$ script1.php?s=ss&c=cc&p=all [NC,L]
RewriteRule ^script1/ss/cc/all/$ script1.php?s=ss&c=cc&p=all [NC,L]

RewriteRule ^script2/ss/cc/dd/all$ script2.php?s=ss&c=cc&d=dd&p=all [NC,L]
RewriteRule ^script2/ss/cc/dd/all/$ script2.php?s=ss&c=cc&d=dd&p=all [NC,L]

RewriteRule ^script3/ss/cc/dd/gg/all$ script3.php?s=ss&c=cc&d=dd&cg=gg&p=all [NC,L]
RewriteRule ^script3/ss/cc/dd/gg/all/$ script3.php?s=ss&c=cc&d=dd&cg=gg&p=all [NC,L]


Hope this helps.
Addy
0
Aidam-UnlimitedAuthor Commented:
Hi Addy, thanks for fast response.

I forgot to mention that variable values are changeable.

So everything what is fixed is script name and variable name, but variable value is always different.
For example, s=abc, s=jdcjsdcksn.

Thanks
0
Avinash ZalaWeb ExpertCommented:
so change rule to below


RewriteRule ^script1/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ script1.php?s=$1&c=$2&p=$3l [NC,L]
RewriteRule ^script1/ss/cc/all/$ script1.php?s=ss&c=cc&p=all [NC,L]

RewriteRule ^script2/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ script2.php?s=$1&c=$2&d=$3&p=$4 [NC,L]
RewriteRule ^script2/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ script2.php?s=$1&c=$2&d=$3&p=$4 [NC,L]

RewriteRule ^script3/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ script3.php?s=$1&c=$2&d=$3&cg=$4&p=$5 [NC,L]
RewriteRule ^script3/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ script3.php?s=$1&c=$2&d=$3&cg=$4&p=$5 [NC,L]


Hope this helps
Addy
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aidam-UnlimitedAuthor Commented:
Excellent, perfect. Thanks a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.