How to “redirect” from main page in Prestashop to specific product page? - .htaccess

This question is the same one that was asked on Feb 24.
I applied the answer using my site product page which is:
Redirect 301 / http://www.papasworkshop.net/home/8-the-lifter-scrollsaw-arm-lift-assembly.html
The error message I receive is WEBPAGE NOT AVAILABLE
The URL line contains:
http://www.papasworkshop.net/home/8-the-lifter-scrollsaw-arm-lift-assembly.htmlhome/8-the-lifter-scrollsaw-arm-lift-assembly.html (and all of this text- except for the web address - repeats many many times on the URL line.

Try using RedirectMatch instead because Redirect links two different path nodes together. Meaning, / gets symbolically linked to http://www.papasworkshop.net/home/8-the-lifter-scrollsaw-arm-lift-assembly.html
. Thus anything after the / also appears at the end of http://www.papasworkshop.net/home/8-the-lifter-scrollsaw-arm-lift-assembly.html.
Incidentally, that means you're browser will continue to loop and constantly get redirected by the server. So try:
RedirectMatch 301 ^/$ http://www.papasworkshop.net/home/8-the-lifter-scrollsaw-arm-lift-assembly.html

You need to create a .htaccess file in the /home subdirectory with the following line:
RewriteEngine On

Related

How to make 301 redirect from one website to another where the ending is different?

I have 2 websites:
OLD one - https://www.old.example/en/
NEW one - https://new.example/en
Lastly, Google Search Console reported around 80 improperly redirected links for OLD website, i.e.:
https://www.old.example/en/?p=41310
https://www.old.example/en/?p=45659
https://www.old.example/en/?p=72785
In .htaccess of OLD page is inputted only code:
Redirect 301 / https://new.example/
which redirects above links from OLD page to i.e.
https://new.example/en/?p=62692
How can I correct it and i.e. expect to have in such cases always redirection to main page - https://new.example/en
To remove the query string completely (without a stray ? at the end) you'll need to use mod_rewrite instead.
For example, in the .htaccess at the old domain:
RewriteEngine On
RewriteRule ^(en)/ https://new.example/$1 [QSD,R=301,L]
Aside: Although this many-to-one redirect will likely be seen as a soft-404 by Google.

301 Redirect Issues in .htaccess file

I've been digging through the archives and threads and can't seem to find anything that matches my 301 Redirect issue -
I am trying to redirect old links to a new site and a problem with the following:
This one works - Redirect 301 /food-service/ http://www.xxxx.com/food-services.html
This one does not - Redirect 301 /food-service/distribution http://www.xxxx.com/distribution.html
The one that does not work tries to redirect to - http://www.xxxx.com/food-services.htmldistribution/
Would you mind lending me your thoughts on what I can do?
Thank you all!
The documentation for Redirect says:
Then any request beginning with URL-Path will return a redirect request to the client at the location of the target URL. Additional path information beyond the matched URL-Path will be appended to the target URL.
The behaviour that you do observe is as we would expect from the documentation. It goes through the Redirect directives, and chooses the first one that matches.
To get the correct behaviour, you have to list the most specific redirect first, and the least specific last.
If you would have rules for /a/b/c, /a/b and /a, then you list them in that order.

Is there a 301 wildcard match?

I am having great difficulty fielding all the 301 redirects that seem to be needed following a complete site redesign. Entire sub-directories and their extensive content no longer exist. If, for example, 'myolddata' was a folder that no longer exists, and was full of countless files that each no longer exists either, I would like to say "forget all that and just go to the index page". There seems no other way of closing the door on Google & Bing endlessly reporting squillions of 404's to me. Is there a way of saying in effect:
Redirect 301 /myolddata/ /index.html
Redirect 301 /myolddata/* /index.html
where the first says 'forget the folder' and the second says 'and forget everything tht was in it'?
The second part to this issue is that old PHP files and their arbitrary search parameters are logged too. Stuff like:
oldfile.php?this=1&that=2&somethingelse=3
oldfile.php?this=Tom&that=Dick&somethingelse=Harry
You get the picture. Millions of them. How can I set up a 301 to say "forget oldfile.php and any parameter with it imaginable - they are all gone!"
Your assistance, comments and advice would be incredibly valuable, so all insights welcome please!!
Better use mod_rewrite rules for this using 301 status code. Use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^(oldfile\.php$|myolddata(/|$)) /index.html? [L,NC,R=301]
? in the end will strip any existing query string.

.htaccess redirect to different domain only if URL is invalid

I am trying to create a .htaccess rule to redirect users from one domain to the other, but this should happen only if the original URL does not exist. For example:
www.domain.com/100 to www.otherdomain.com/PersonalPages/100
www.domain.com/150 to www.otherdomain.com/PersonalPages/150
Now, I don't have a page/file named 100 or 150, so that's why it should redirect, but if user enters "www.domain.com" I do have "index.php" and should stay in "www.domain.com" and not try to go to "www.otherdomain.com/PersonalPages/index.php" (or any other if page exist in my www.domain.com)
I know I can create a simple 301 redirect, but the numbers in the URL are the IDs of users and that number will grow on a daily basis so I can't be adding lines of redirects to my .htaccess for each new user.
Is there a 404 code I could use?
I think this will work for you:
RewriteRule ^([0-9]+)$ http://www.otherdomain.com/PersonalPages/$1
^ and $ mark the beginning/end of the url, [0-9]+ stands for one or more numbers between 0 and 9.

htaccess redirection matching urls to grandparent directory

A search engine keeps hitting my site regularly for non-existing pages that it randomly generates. I want to put an end to this silliness using a 301 rule in my htaccess file.
The most usual address is
site.tld/blog/welcome-back/x/xx/
where x is a random number but sometimes I get hits on
site.tld/blog/welcome-back/xx/xx/
or text instead of numbers.
I want to redirect all these hits to the real existing page
/blog/welcome-back/
Thanks in advance for any help!
This should do what you need:
RewriteEngine On
RewriteRule ^blog/welcome-back/.+$ http://site.tld/blog/welcome-back/ [R=301,L]

Resources