PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 3, 2022

[FIXED] Redirect Rule htaccess WordPress

 March 03, 2022     .htaccess, redirect, wordpress     No comments   

Issue

Hi I want to redirect URLs from /search/label/anything to /search/anything

I am new to redirects, I know it may be simple.

Another problem, I want to redirect specific URL which is /search/label/اضافات بلوجر to /blogger

the URL contains 2 Arabic words with a space separating them.

I tried this Rule but It does not work:

Redirect 301 /search/label/اضافات بلوجر https://mobtakr.com/blogger/

Any solutions? Thank you in advance


Solution

I found the answer to my question. I want to add it for anyone that will have the same problem.

To redirect from /search/label/اضافات بلوجر to /blogger, I have used RedirectMatch with this regular expression اضافات\sبلوجر,

The final redirect rule is as follows:

RedirectMatch 301 /search/label/اضافات\sبلوجر https://mobtakr.com/blogger/

And to redirect URLs from /search/label/anything to /search/anything I have used this rule:

RedirectMatch 301 /search/label/([^/]+) https://mobtakr.com/search/$1

the regex [^/]+ simply matches anything that is not a slash.

So, Hope this is helpful to you.



Answered By - Mohamed Gad
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing