Redirect to new folder - .htaccess

To change the name of a directory, I have created a new duplicate directory, and wish to redirect calls for the old one to the new one. This is in the root directory’s htaccess.
Redirect 301 /as/oldarchive/ /as/newarchive/
Both addresses respond correctly when called from the browser address bar. But the redirect does not work.
(The directory has only one main page, an updating bulletin, reached by htaccess DirectoryIndex statement. It uses no additional file call, and the file name is not seen by users.)
How should this redirect be written?
Note: The root directory is a first-level subdirectory of my main site. It is called directly with its own URL. Thus:
http://othersite.net/as/oldarchive/
is actually located here:
http://mainsite.net/othersite.net/as/oldarchive/
But placing a redirect in the main site's htaccess, reflecting this nesting, also doesn't work.
Thank you.

Related

TYPO3 10 .htaccess redirect old links to new links not working

While updating a website (completely new page tree, IDs have changed), the old links need to redirect to the new links. Domain stays the same.
This is the first thing I write in my .htaccess
RewriteEngine on
Redirect 301 /index.php?id=5 /contact
Redirect 301 /test.html /xy.html
Redirect 301 /index.php?id=6 /imprint
# and many more
test.html successfully links to xy.html (just a test, they don't even exist and correctly show the 404 page)
the index.php?id=x redirects however do not work. They actually still open whatever new page has this ID.
I don't understand why it's not working. Is TYPO3 interfering? I though I would be safe if I write it as the first thing in my .htaccess.
TYPO3 does not interfere as the rules in the .htaccess file are evaluated before.
Another option could be to use the redirect module of TYPO3 for creating the redirects. Those can then be created in the backend and maintained by editors. A small drawback is that performance is not that perfect as in .htaccess but it is much more convenient.

How do I rewrite old URLs without affecting default redirects?

Let me see if I can explain this.
I used to have mydomain.com as my default page. The login page would be mydomain.com/login and every content created would become mydomain.com/topic1, mydomain.com/topic2 etc.
But I have created a subdirectory, so it's now mydomain.com/sub/login and mydomain.com/sub/topic1 etc.
I then set mydomain.com to redirect to mydomain.com/sub/login via my host's panel (Hostinger).
If a user accesses the website from one of the old links, I would like it to change the URL to include the new subdirectory automatically, without affecting the redirect I have created.
How can I do so? Is it possible?
Thanks, folks!

Is it possible using .htaccess file to keep / and all links in a subfolder?

I have a website example.com with a subdirectory of example.com/admin/, I want to put a .htaccess file in my /admin/ directory so that if I create a link like this Home that it will stay in example.com/admin/ and not go to example.com/.
I know I could just do Home, but want an over all solution where I don't have to do that to all links, encase at a later time I decided to rename the /admin/ directory.
You can not do that with .htaccess. Because it is not on the server that it happens, but in the browser.
But it is possible to redirect some pages, If it is possible to recognize them, for example by name.
You can redirect all admin-xxxx.html pages to admin/admin-xxxx.html

htaccess redirect entire site to one directory

What I want to do is very simple but cant find the unique solution anywhere. I want to redirect all files and folders in the site to a single directory.
Redirect domain.com/ and domain.com/* to domain.com/folder/
Basically all strings typed into the url is redirected to the subfolder hiding the entire site from the public and redirecting to a splash page with the condition of ![ip address]

How to use .htaccess to redirect to new website?

I have the website
http://oldname.edu/gailp2/CSSS508,
which I want to point to my new site,
https://newsite.com/site/gailp2csss508
I've tried a number of different ways to accomplish the redirect via .htaccess files.
First, I modified the .htaccess file in the folder CSSS508
as follows:
Redirect 301 / https://newsite.com/site/gailp2csss508
When I navigate to the old site (oldsite.edu/gailp2/CSSS508), I get the error
"We're sorry, we were unable to locate the site /gailp2csss508gailp2/CSSS508"
It seems to be concatenating the file directories onto the name of the new website??
I've also tried a number of different variations, for example, trying to modify .htaccess files in different directories -- all unsuccessful.
try this Redirect 301 /gailp2/CSSS508 https://newsite.com/site/gailp2csss508

Resources