Need help with htaccess

DerangedWolf

Elite Member
Jr. VIP
Joined
Apr 30, 2018
Messages
1,924
Reaction score
1,512
Hello,

I have this redirection code in htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_t=\d+/?$ [NC]
RewriteRule ^ / [R=301,L,QSD]
Redirect 301 /c/system/ /t/system
</IfModule>

It redirects the given page perfectly, but if there's a number or letter after the slash, it won't work. Example: /c/system/8 doesn't redirect.

Can you please help me redirect /c/system/ with anything after the slash to /t/system?

Regards
 
Use the following code:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_t=\d+/?$ [NC]
RewriteRule ^ / [R=301,L,QSD]
RedirectMatch  301 /c/system/.* /t/system
</IfModule>

We are using RedirectMatch instead of Redirect so that we can use regex.
 
Use the following code:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_t=\d+/?$ [NC]
RewriteRule ^ / [R=301,L,QSD]
RedirectMatch  301 /c/system/.* /t/system
</IfModule>

We are using RedirectMatch instead of Redirect so that we can use regex.
Thanks for your reply.

It doesn't work. It redirects /c/general/8 to /c/general8
 
So, do you wish to redirect this /c/[ANYTHING]/[ANYTHINGELSE] to /t/system?
 
I am confused.
I am too haha. I checked the redirection using online Redirection checkers as well in case the redirection is cached on my system but it still redirects to wrong page according to the online checker.
 
I wish to redirect /c/system/[ANYTHINGELSE] to /t/system
Yeah because you said you wanted only this. It doesn't redirect /c/general/8 because nowhere did you mention such a redirect to take place in your replies.
 
Last edited:
Yeah because you said you wanted this. It doesn't redirect /c/general/8
[ANYTHINGELSE] means 8 or 9 or 10 or 1u3hgbwmbgor or 17875834 or literally anything.

So:

/c/system/8
/c/system/462
/c/system/sdvbsdv
/c/system/26547
/c/system/22

Should all redirect to /t/system
 
[ANYTHINGELSE] means 8 or 9 or 10 or 1u3hgbwmbgor or 17875834 or literally anything.

So:

/c/system/8
/c/system/462
/c/system/sdvbsdv
/c/system/26547
/c/system/22

Should all redirect to /t/system
And it does please check the htccess tester again by entering these URLs. My example contained the URL that you had trouble with /c/general/8
 
Try this:

Code:
RewriteRule ^c/system(/(\d+)|)$ /t/system [L,R=301]

It works for:

/c/system
/c/system/5

If you want to redirect everything, not only numbers then:

Code:
RewriteRule ^c/system(/(.*?)|)$ /t/system [L,R=301]

/c/system
/c/system/5
/c/system/blabla
/c/system/BlaBla123
 
Try this:

Code:
RewriteRule ^c/system(/(\d+)|)$ /t/system [L,R=301]

It works for:



If you want to redirect everything, not only numbers then:

Code:
RewriteRule ^c/system(/(.*?)|)$ /t/system [L,R=301]
Site is giving 500 Internal Server Error after I added it
 
Site is giving 500 Internal Server Error after I added it

You added it to the wrong place in your .htaccess code or there's something else wrong in your .htaccess. Check the error_log file for more information.
 
Back
Top