Php 使用htaccess重写跳过文件夹名称的URL

Php 使用htaccess重写跳过文件夹名称的URL,php,apache,.htaccess,url,mod-rewrite,Php,Apache,.htaccess,Url,Mod Rewrite,我有一个列出教育中心的网站。我有两个疑问 我有一个URL,可以打印这样一个大学的详细信息 www.example.com/education/eduS.php?Main=colleges&Name=nameOfCollege 我这样写这个网址 www.example.com/education/colleges/nameOfCollege 我的访问权限是 RewriteRule ^(.*)/(.*)$ eduS.php?Main=$1&Name=$2 [L,NC,QSA] 我的问

我有一个列出教育中心的网站。我有两个疑问

  • 我有一个URL,可以打印这样一个大学的详细信息

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

  • 我这样写这个网址

    www.example.com/education/colleges/nameOfCollege
    
    我的访问权限是

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

    • 我想从我的url中跳过文件夹名eduaction,以便获得如下url

      www.example.com/colleges/nameOfCollege 这是怎么可能的。我想获取Main和Name作为get参数

    • 我的第二个问题是,我有另一个url在一个页面中列出学院名称。像这样的url

      www.example.com/edu/edu.php?Main=colleges&Category=Engineering colleges 我这样重写

      www.example.com/education/colleges/Engineering colleges 我的htaccess

      RewriteRule^(.)/(.)$edu.php?Main=$1&Category=$2[L,NC,QSA] 但这显示出一点混乱。上述两个URL具有相同数量的GET参数。我如何处理这个问题

    • 我还需要跳过第二个URL中的相同文件夹名称。有人帮我吗


    文档root/.htaccess
    中使用此代码:

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

    这允许您的URL像:
    /colleges/nameOfCollege

    谢谢您,先生。在我上面的第二个问题中,我如何处理两个具有相同数量和相同类型参数的URL。您的另一个规则是在
    /education/.htaccess
    中,它是用于
    /education/colleges/nameOfCollege
    URL的,而这个是用于
    /colleges/nameOfCollege
    先生,我的本地主机不工作。找不到对象错误显示此.htaccess的位置是什么?您是否尝试过:
    www.keralaspot.com/colleges/nameOfCollege
    ?sir/colleges/nameOfCollege和/colleges/Category two URL具有相同数量和类型的参数。URL重定向不正确