How do I move all traffic from one folder to the home page with  htaccess redirect?

jblayney
jblayney used Ask the Experts™
on
I am trying to set up a simple htaccess redirect, I want to move all traffic from one folder to the home page

I copied and pasted this code from another server that has been using it for years,

when I test it, i get a safari timeout error "Safari cant open page, too many redirects.."


this is my code, in a wordpress site, at bottom of .htacess below wordpress, toast, other plugins code

RewriteEngine On
Options +FollowSymLinks -Indexes

redirect 301 /mce_activity https://oala.ca/

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kyle SantosSoftware Test Analyst I at Dassault Systemes

Commented:
Hi,

I am following up on your question.  Do you still need help?

If you solved the problem on your own, would you please post the solution here in case others have the same problem?

Regards,

Kyle Santos
Customer Relations

Author

Commented:
this was never solved
Top Expert 2004

Commented:
When I browse to "https://oala.ca/mce_activity", I do receive a 301 redirect to "https://oala.ca", with no errors.  This is in Chrome, Opera, and Edge.  In my old Safari for Windows, I get an error that a secure connection cannot be established with your server, but no redirection at all.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Strange that this happens just with some browsers.
My suspects list would be
1 - browser cache
2 - browser
3 - vhost and https redirect

1 - clear browser cache and any cookie related to the site, then close browser, restart your computer, reopen it, test
If NOOK check with same browser from another machine, preferably that never went to the site

2 - check your safari setup for privacy and redirections. Have a look at https://www.techwalla.com/articles/how-to-prevent-redirects-in-safari or similar info

3 - check all lines in your htaccess
Check the vhost file for all redirections. Is there in the vhost or in the wordpress settings any redirection? A http redirect to https?

Good search!
Please post your tests results here.
Top Expert 2004

Commented:
My secure error is probably a result of the old browser software - Apple stopped updating Safari for Windows quite some time ago.  The Safari results would be much more relevant if they could be reproduced in a more current environment (i.e., Safari on a Mac).

Since my first post, I also tested with Firefox, and I see the same behavior as with Chrome, Opera, and Edge.  From all appearances, this appears to be resolved.
Kyle SantosSoftware Test Analyst I at Dassault Systemes

Commented:
jblayney,

Experts have responded.  Is there anything else we may assist you with?

Regards,

Kyle Santos
Customer Relations
Fractional CTO
Distinguished Expert 2018
Commented:
Important: Never do a 301, as browsers cache 301 requests for long periods. There's no RFC for how long 301s lodge in browser caches, so rarely are 301s correct to use.

Just know, once you use a 301 + have an error in your target link, you have to guess all visitors will have this error cached forever + will never see any change you make to your 301 target.
_______

How you do this depends on many factors. Most important relates to the mce_activity path component + if anything else will tack on the end of this directory, like other path components or query parameters.

Try this to only redirect the single path component + query parameters...
RewriteRule ^mce_activity/?$ https://oala.ca/?%{QUERY_STRING} [L,R=302]

Open in new window

To catch + pass additional path components will depend on exact format of source (mce_activity/...) format.
David points to the essential part: redirect the query string as well... this would avoid most infinite loops!

Ooops... I wanted to post this comment just before closing the question... which is now delayed

Author

Commented:
Hello,

I cannot seem to pick a solution of this, I have tried a few times
Did you try the redirect as suggested by David?

Author

Commented:
It seemed to be a Safari caching issue, even after dumping and blocking cache, it just cleared up after 2 weeks..

his code also works
safari caching issue:
- this enforces David' suggestion
- did you test from another computer as I suggested? this might have pinpointed that the issue was not on "all Safaris"

Author

Commented:
yes, my phone and PC, can we close this please. I moved on from this project weeks ago
Kyle SantosSoftware Test Analyst I at Dassault Systemes

Commented:
Hi jblayney,

You will have some options that look like this on your screen.
Screenshot_1.png
If you want to award experts points for their help you can select on their comments as 'No, but this was helpful'.
When you're done doing this, select the one comment as 'Yes, this is my solution!'

When you're all done with selections proceed with closing your question and you're done.

Let me know if you have any questions.

Regards,

Kyle Santos
Customer Relations

Author

Commented:
Yes I saw those, Like I posted already, I cannot click on those links, I tried many times. I am on Safari 11.1.1 on a Mac
Kyle SantosSoftware Test Analyst I at Dassault Systemes

Commented:
I will get on a Mac and try to reproduce the issue you're having on Safari!  So sorry its not working for you.  I'll write back soon.
Kyle SantosSoftware Test Analyst I at Dassault Systemes

Commented:
jblayney,

Thank you for reporting this issue.  It turns out there is a bug and we are going to fix it soon.  In the meantime, I have closed this question for you.  We appreciate your patience and understanding with us on this.  If you need anything else please let me know.

Regards,

Kyle Santos
Customer Relations

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial