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 variablesqr$id
, redirectingedus.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
Post a Comment