I'm quite lost and didn't understand quite well when I'm self researched.
I did a redirect like this
Redirect 301 /aaa/aaa /bbb/bbb
but when I goes to aaa/aaa, it was redirected to /bbb/aaa
I understand (assumed) that it was because I already have a this line
Redirect 301 /aaa /bbb
There were about 60 redirection line implemented at the same time, but only some of 'em got this issue. I'm not very familiar with the coding field, so I'm open for any advices.
Thank you
Related
I couldn't find an answer, how to redirect certain subcategories...
I've old shop with paths like that:
shop.com/old_cat1/old_cat2/old_cat3
What I want, is to redirect it like that:
shop.com/new_cat2
shop.com/new_cat3
When I'm trying to use this code:
Redirect 301 /old_cat1/old_cat2/ https://shop.com/new_cat2
Redirect 301 /old_cat1/old_cat2/old_cat3 https://shop.com/new_cat3
redirection from old_cat2 to new_cat2 is working, but redirection to new_cat3 is sending me to new_cat2 (higher level). What should I do? I was trying with RedirectMatch, but it gave me nothing.
I am using simple mod-rewrite rule:
Redirect 301 /feeds/ https://some-interesting-website.../feed/index.php
It doesn't work because if I have some link:
/feeds/some-difficulf-link/many-files-and-folders.php than result is:
https://some-interesting-website.../feed/index.phpsome-difficult-link/many-files-and-folders.php
How could I remove a rest of a link after index.php?
It was really hard job. I was need to pay a lot of time and efforts in it to find a solution.
Looks like mod rewrite logic is not very clear. However this code worked perfect for me: Redirect 301 /feeds https://some-interesting-website.../feed/index.php?
I've consolidated about 20 old pages into one new page, and want to redirect web links going to those pages to the new page.
I started out listing each one in htaccess as a Redirect 301, but thought I might save processing time to do a wildcard string match instead. Unfortunately it failed, because I suspect the page I want to go to is also caught in the wildcard.
For example I want to redirect, www.mydomain.com/catalog/listname_oranges.php, listname_lemons.php, listname_figs.php etc to redirect to www.mydomain.com/catalog/listname_addons.php
So I tried this, which failed:
RedirectMatch 301 ^/catalog/listname_.*$ /catalog/listname_addons.php
How do I fix this so its not recursive?
You can use a negative lookahead in your regex:
RedirectMatch 301 ^/catalog/listname_(?!addons\.php).*$ /catalog/listname_addons.php
This way, the listname_addons.php file won't match the regex but everything else will.
I was wondering what would be the correct way to do a redirect like this:
Redirect 301 /about/$ http://domain.com/new-about/
Redirect 301 /about$ http://domain.com/new-about/
Redirect 301 /about/me http://domain.com/new-about/
That's how I currently do it and it works but I believe there should be a better way?
I have 2 pages which are rewrited, one page is a subpage of the other page /about/me/, now both pages should redirect to the new page new-about
You should either use RedirectMatch or use mod_rewrite to perform regular expression matching. This should work and would be the shortest and best performing solution:
RedirectMatch 301 ^/about /new-about/
Domain and protocol are optional - leaving them out like this will keep them as they were, so this is future proof.
Been a while since I asked this question and I am now more comfortable with regular expressions.
The way I would do this now is:
Redirect 301 ^/about http://domain.com/new-about/
A tool which helped me a lot understanding regular expressions and which I would advice anyone trying to understand them is Rubular: http://rubular.com/
I've got:
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
which works fine, unless followed by:
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/blog/$2
I've tried all kinds of versions, including RewriteRule, but nothing has worked. How do I keep the first specific rule, and write an "everything else keeps its request uri and query string" rule?
Thanks
Alright, assuming these are the only two lines, what I see is this:
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/blog/$2
These are basically saying the same thing, that is, on a match, permanently redirect all blog queries to the new site.
With the second one you're saying match from the beginning the string /blog with a possible slash, which you'll capture, and possibly more information, which you'll also capture, then just put all that information into blog/extra-picked-up-info. This may be part of the problem, or you may be able to get around it by reordering the directives, and seeing if the lower directive receives precedence.
RedirectMatch 301 /blog(?:/\?)?(.*)?$ http://www.new-site.com/blog/$1
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
Otherwise, you're going to need to reexamine your URIs, and find something more uniquely identifying.