php - How to extract variable part from URL and how to know if URL variable is appended by digits? -


i have url this:

www.example.com/education/edu.php?main=colleges&category=engineering-colleges 

i rewrite url using .htaccess

www.example.com/education/colleges/engineering-colleges 

also have url in same education directory like:

www.example.com/education/edus.php?main=colleges&collegeid=$id&collegename=$name 

i want rewrite url this:

www.example.com/education/colleges/$name-sqr$id 

how can accomplished? can't think of way because above 2 rewrite urls have same number of parameters. can't redirect them correct page.

these questions:

  • is there way using .htaccess validating url variable sqr$id , redirecting edus.php page.
  • how extract id url , make variable operation in page.

try code in /education/.htaccess:

rewriteengine on rewritebase /education/  rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l]  rewriterule ^([^/]+)/([^-]+)-sqr([0-9]+)/?$ edus.php?main=$1&collegeid=$3&collegename=$2 [l,qsa,nc]  rewriterule ^([^/]+)/([^/]+)/?$ edus.php?main=$1&category=$2 [l,qsa] 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -