简体   繁体   English

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

[英]Link is fine yet .htaccess redirecting to wrong page

I already succeded to redirect it like this, but there is two redirections. 我已经成功完成了这样的重定向,但是有两个重定向。 The first one is redirecting category name, the other one is redirecting the subject name. 第一个是重定向类别名称,另一个是重定向主题名称。 But somehow in some links it redirecting category URL's to subject page. 但是在某些链接中,它以某种方式将类别URL重定向到主题页面。

This is the original url: 这是原始网址:

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

and I want to redirect it to: 我想将其重定向到:

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

Here is my .htaccess code: 这是我的.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]  

The result i got is ending with "k2.php" yet its acting like "s2.php" 我得到的结果以“ k2.php”结尾,但其行为类似于“ s2.php”

I've solved the problem by adding -1 and -2 for each line like this: 我已经通过为每行添加-1和-2来解决此问题,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM