|
2021-03-01, 01:56 PM | #1 |
Life is good
|
301 Redirect
Trying to redirect everything that comes into a folder, problem is it's often subfolders within it. Any ideas?
.htaccess: RewriteRule ^/(.*)$ https://domain.com/site/$1 [L,R=301] Placing it in domain.com/site/scene/ folder so when someone lands on domain.com/site/scene/757/1922/her-video they get redirected to just https://domain.com/site/ Anyone? |
2021-03-10, 11:22 PM | #2 | |
Asleep at the switch? I wasn't asleep, I was drunk
Join Date: Apr 2005
Posts: 214
|
Quote:
I will test for a second and let you know. Last edited by sarettah; 2021-03-10 at 11:52 PM.. |
|
2021-03-10, 11:48 PM | #3 |
Asleep at the switch? I wasn't asleep, I was drunk
Join Date: Apr 2005
Posts: 214
|
I set up a test at https://madspiders.com/htaccess_test/
In the root directory I have just an index.htm page that will show "Main Page". I have a subfolder called subfolder1. in there is an .htaccess file that looks like this: RewriteEngine On RewriteRule ^(.*)$ ../ In there is also another index.htm page that if it gets hit will show "subfolder1" So anything hitting there should be redirected to the main folder one step down. And it does that. https://madspiders.com/htaccess_test/subfolder1/ Inside of subfolder1 I have a subfolder called subfolder2. That has an index.htm page that will show "subfolder 2" if it gets hit. There is no .htaccess file in subfolder2. So the .htaccess folder in subfolder1 controls the rules and subfolder2 never shows because the hit is redirected to the Main folder. https://madspiders.com/htaccess_test...r1/subfolder2/ Inside subfolder2 I have a subfolder called (can you guess?, yeppir), subfolder3. That has an index page that when it gets hit will show subfolder 3. It also has an .htaccess file with just one line RewriteEngine Off That turns off the redirect at that level and lets you see subfolder3. https://madspiders.com/htaccess_test...r2/subfolder3/ So, like I say, you should be able to do the redirect of everything subfolders and all with just 1 htaccess file at the proper level. Hope that helps and I hope it answered the question, lol. Hate to type that much and find out I misinterpreted the question. . Last edited by sarettah; 2021-03-10 at 11:51 PM.. |
|
|