链接很好.htaccess重定向到错误的页面

时间:2017-07-27 16:38:36

标签: php .htaccess mod-rewrite url-rewriting

我已经成功将其重定向,但有两个重定向。第一个是重定向类别名称,另一个是重定向主题名称。但不知何故,在某些链接中,它将类别URL重定向到主题页面。

这是原始网址:

  

http://asite.net/test/category.php?catid=[numbers]

我希望将其重定向到:

  

http://asite.net/test/the-name-of-the-category-k1.php

这是我的.htaccess代码:

<Files 403.shtml>
order allow,deny
allow from all
</Files>
RewriteEngine on
Options +FollowSymLinks 
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteRule ^(.*)-s(.*).php$ subject.php?subj=$1&-s=$2[L,NC]  
RewriteRule ^(.*)-k(.*).php$ category.php?catid=$1&-k=$2[L,NC]  

我得到的结果是&#34; k2.php&#34;但它的表现就像&#34; s2.php&#34;

1 个答案:

答案 0 :(得分:0)

我通过为每行添加-1和-2来解决问题:

  

RewriteRule ^(。) - 2-s(。)。php $ subject.php?subj = $ 1&amp; -s = $ 2 [L,NC]
  RewriteRule ^(。) - 1-k(。)。php $ category.php?catid = $ 1&amp; -k = $ 2 [L,NC]