0
votes

I have a website for listing education centers.I have two doubts.

  1. I have a URL for printing one college details like this

    www.example.com/education/eduS.php?Main=colleges&Name=nameOfCollege

I rwrite this url like this

www.example.com/education/colleges/nameOfCollege

my htaccess is

RewriteRule ^(.*)/(.*)$ eduS.php?Main=$1&Name=$2 [L,NC,QSA]  

My problem is that

  • I want to skip the folder name eduaction from my url so as to get URL like this

    www.example.com/colleges/nameOfCollege How it is possible. I want to get Main and Name as GET parameters.

  • my Second problem is that , I have another url for listing colleges name in one page. The url like this

    www.example.com/education/edu.php?Main=colleges&Category=Engineering-colleges I rewrite like this

    www.example.com/education/colleges/Engineering-colleges my htaccess

    RewriteRule ^(.)/(.)$ edu.php?Main=$1&Category=$2 [L,NC,QSA] but this shows little bit confusion. The above two URL have same number of GET parameters. How can I handle this problem.

  • I also need to skip same folder name education from the second URL. Anyone help me

1

1 Answers

0
votes

Use this code in your DocumentRoot/.htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ education/eduS.php?Main=$1&Name=$2 [L,QSA]

This allows you to have your URLs like: /colleges/nameOfCollege