简体   繁体   中英

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.

This is the original url:

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

Here is my .htaccess code:

<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"

I've solved the problem by adding -1 and -2 for each line like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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