How to remove part of URl with .htaccess?

后端 未结 5 490
星月不相逢
星月不相逢 2020-12-09 20:28

Currently i have 20+ URLs on my site in this formate

http://www.example.net/content/index/mission

I want to remove /content/index from all URLs, so they shou

5条回答
  •  孤街浪徒
    2020-12-09 21:07

    I'm going to guess you already have some rewrite rules in place for URLs like http://www.example.net/content/index/mission

    You need to find these rules and add a new one which uses a similar structure but 'hard codes' the content/index parts, for example, suppose the existing one was

    RewriteRule ^content/(.*)/(.*)$ /content.php?param1=$1¶m2=$2 [L,qsa]
    

    You'd want to make a new rule to pick up /mission and rewrite it in a similar way, but before the existing rule kicks in, e.g.

    RewriteRule ^mission$ /content.php?param1=index¶m2=mission [L,qsa]
    RewriteRule ^content/(.*)/(.*)$ /content.php?param1=$1¶m2=$2 [L,qsa]
    

    These are just examples - it will really depend on what your existing rules are.

提交回复
热议问题