Welcome to the Shiny club of Kirby! (2021)

Try this.

Create a new .htaccess file in /folder1 and add this

Redirect 302 /old-page.html http://yoursite.com/newpage.html

If you want it as a permanent redirect, change the 302 to 301

2 Likes

If I wanted to redirect everything on that folder would I have to do it one by one or is there another way?

Ok, add this one instead

RedirectMatch 301 ^/(.*)$ http://domain.com/$1

Place this in an .htaccess file in /folder1 and replace domain.com with the URL. Make sure the “/$1” stays at the end though.

Note: I have never tested this, so it may not work, let me know if it does/doesn’t.

Nope doesn’t work.

It works for me, just tested it on an IF site

RedirectMatch 301 ^/(.*)$ http://domain.com/$1

I added an .htaccess file in a new directory (For test purposes) and changed “domain.com” to a different site. When I enter a URL, the page on the site I am redirecting to (the one that replaced “domain.com”) is brought up.

Ex. My domain is examplesite.com and I want to redirect my pages to epicdomain.com
I add this line and change domain.com to epicdomain.com (Because that is what I want to redirect to).

RedirectMatch 301 ^/(.*)$ http://epicdomain.com/$1

To test, I go to examplesite.com - Diese Website steht zum Verkauf! - Informationen zum Thema example site. (This page may or may not exist, it does not matter) and I am redirected to epicdomain.com/mypage.html (Witch does exist, if it did not, I would get epicdomains.com’s 404 page).

Hope this makes sence :slight_smile:

@Technical.Legendz Try this:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /folder1/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!folder1/).*)$ folder1/$1 [L,NC]

@Greenreader9 He is not asking for redirection but hiding the folder name in url but also keeping the files in that folder. This is a technique for two things:

  1. When your application requires a specific folder to be the root of your files but you don’t have the permission to change it.
  2. While proxying http servers which are powered with something like node.js, python etc with apache/ngnix, You must upload your static and public files inside a specific folder or else the fatal server files will be visible, especially if they contain sensitive data. Since we only want static files to be accessible, you can use the code I’ve provided above.
3 Likes

He doesn’t use IF anymore lol
The server we use has a very very different configuration.

1 Like

What’s the difference though?

The server process .htaccess files differently. Some things work and some things don’t.

I’ve tried what you’ve said, however it doesn’t work as expected.

So the files are finally showing up with the directory removed, but now all the files that were under the root folder are not showing up (like the index file for the site)

Can you elaborate?

Ok.
So htdocs/folder1/a.html can be seen on domain.com/a.html
But htdocs/b.html cannot be seen on domain.com/b.html.

Note: I placed your code on /htdocs/.htaccess and not on the subfolder or root folder if that was what I was meant to do.

Well what do you expect? You configured it to look for requests in the directory.

HTML5 and Javascript.

1 Like

Oh right, forgot to say that htacceas code only fetches from that folder.

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /folder1/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteCond %{REQUEST_URI} !/folder1/
RewriteRule ^((?!folder1/).*)$ folder1/$1 [L,NC]
1 Like

Well what I gave is also bugged :expressionless:

What about routing all the urls to php and setting if else methods there?

1 Like

wdym?

Having a URL Router and handling all the pages from one file. Kinda like how NodeJS and Python work.

Exactly.