• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

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
0
Aidam-Unlimited
Asked:
Aidam-Unlimited
  • 2
  • 2
1 Solution
 
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
 
Aidam-UnlimitedAuthor Commented:
Excellent, perfect. Thanks a lot!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now