Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Stealth redirection?

SkyWalker_89

New member
Joined
Dec 23, 2024
Messages
5
I'm using software which updates info every five minutes, by uploading all required files to a /image subdirectory.
This includes the index.html file, which also must be in the /image subdirectory.

I'd like my web address to be simply www.mydomain.com/subdirectory, not www.mydomain.com/subdirectory/image.

How can I redirect from /subdirectory to /subdirectory/image, but have it show in the browser as www.mydomain.com/subdirectory?

It's easy enough to redirect, either with an .htaccess file, or just some simple html, but in every case, the browser will show that you are in the /image directory.

It works fine in any event, but it just bugs me seeing the /image in the browser, as it looks like I designed a website with everything in one directory.

Any ideas?
 
To achieve this, you can use URL rewriting with .htaccess (if you're using an Apache server) to internally redirect requests to the /image subdirectory while keeping the URL in the browser as /subdirectory.

Here's how you can do it:
  1. Create or Edit the .htaccess File
    In the /subdirectory folder, create or edit an .htaccess file.
  2. Add Rewrite Rules
    Add the following lines to the .htaccess file:
Apache config:
RewriteEngine On
RewriteBase /subdirectory/

# Rewrite requests to the /image subdirectory
RewriteRule ^$ /subdirectory/image/ [L]
RewriteRule ^(?!image/)(.*)$ /subdirectory/image/$1 [L]
 
Back
Top