I am trying to create the next rule in the .htaccess, but it does not work and I did not find the error. I want to move on from this:
https://www.miblog.com/2018/02/example-5.html
To
https://www.miblog.com/example-5/
I'm trying with this rule.
RedirectMatch 301 ^/20(.*)/([0-9]{1,2})/([0-9]{1,2})/(.*)(/)?$ /$4
This should do the job ;)
RedirectMatch 301 ^/(20)([0-9]{1,2})/([0-9]{1,2})/(.*)\.html$ /$4/
Or that
RedirectMatch 301 ^/(20)([0-9]{1,2})/([0-9]{1,2})/(.*)\.(.*)$ /$4/
Did you have RewriteEngine on right? :)
Try this :
RedirectMatch 301 ^/(20)([0-9]+)/([0-9]+)/(.*)\.html$ /$4/
Note : clear browser cache then test it .
Related
I am trying to use a RedirectMatch to redirect all files under one directory to the main directory:
RedirectMatch 301 ^/question/.*$ https://www.sample.com/
So that if I have a URL like www.sample.com/question/what-day-is-it
It will automatically redirect to www.sample.com/what-day-is-it
The problem is when I put in the RedirectMatch like above, it redirects all URLs to the homepage: www.sample.com/question/what-day-is-it to www.sample.com
If anyone else had the same problem, a simple Redirect 301 /question / did the trick.
I'm trying to create a 301 redirect for some old URLs. An example of an old URL:
http://www.example.com/forum/news/555-subject-test
I want to redirect this to:
http://www.example.com/news/subject-test
I have this:
RedirectMatch 301 /forum/news/(.*)-(.*) /news/$1
However this redirects it to http://www.example.com/forum/news/test
Any ideas how I can fix this? Thank you!
You can use:
RedirectMatch 301 ^/forum/news/[0-9]+-(.+)$ /news/$1
rather than:
RedirectMatch 301 /forum/news/(.*)-(.*) /news/$1
google indexed link:
http://domain.com/category/body-cosmetics/„gloria“-good-quality
I need to redirect to:
http://domain.com/category/body-cosmetics/gloria-good-quality
In htaccess I have code:
RedirectMatch 301 http://domain.com/category/body-cosmetics/(.*)gloria(.*)-good-quality http://www.domain.com/category/body-cosmetics/gloria-good-quality
But its not working...
any ideas ?
Try without the hostname and scheme:
RedirectMatch 301 ^/category/body-cosmetics/(.*)gloria(.*)-good-quality$ http://www.domain.com/category/body-cosmetics/gloria-good-quality
I need redirect url like http://www.sportsinjuryclinic.net/clinics/england/bedfordshire/luton to http://www.sportsinjuryclinic.net/clinics can anyone give me a better solution to redirect..There is 1000's url like this.
Thanks,
You can use this RedirectMatch rule in your root .htaccess:
RedirectMatch 301 ^/(clinics)/.+$ /$1
How can i redirect it to clinics/CA/england/ to the /clinics
RedirectMatch 301 ^/(clinics)/CA/england/ /$1
Can anyone tell me what does
RedirectMatch 301 /([a-zA-Z_]+)-(\d+)-(\d+)-1-([a-z]+)-([a-zA-Z_]+).html http://www.example.com/$1-$2-$3-$4-$5.html
mean in .htaccess file??
This regex is searching for:
[anyChars and_]-[digits]-[digits]-1-[smallChars and_]-[anyChars and_].html
and redirects browser. Ex:
*aaAA-1234-567-1-bbb-cC_c.html*
will be redirected to:
*http://www.example.com/aaAA-1234-567-bbb-cC_c.html*
Also here is a good service to test RegEx: http://gskinner.com/RegExr/