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
Related
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 .
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
My redirect is as follows:
Redirect 301 / http://testsite.com/en/
I get the following address: testsite.com/en/en/en/en/en/en/en/en
I worked in a .htaccess file. Where is my mistake?
You should use RedirectMatch to target precise URL using regex:
RedirectMatch 301 ^/$ http://testsite.com/en/
Make sure to test this after clearing your browser cache.
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/
From .htacces file, how to pass/redirect the FULL URL to another URL as GET Variable?
Like:
http://www.test.com/foo/bar.asp
will be redirected to:
http://www.newsite.com/?url=http://www.test.com/foo/bar.asp
With Full Url with Domain.I tried:
RewriteEngine on
RedirectMatch 301 ^/(.*)\.asp http://www.newsite.com/?url=%{REQUEST_URI}
But it is going out like:
http://www.newsite.com/?url=?%{REQUEST_URI}
RewriteEngine on
RedirectMatch 301 ^/(.*)\.asp http://www.newsite.com/?url=$1.asp
If the initial domain and protocol is always the same then you can use
RedirectMatch 301 ^/(.*)\.asp http://www.newsite.com/?url=http%3A%2F%2Fwww.test.com%2F$1\.asp