Mask URL

Hi Guys

What I want is really simple (Famous last words)

I would like, via an htaccess file to mask in the browser URL the main site for a given directory.

for example the site http://www.thissite.co.uk/adirectory/Whatever.php

to look like this

http://www.thissite.co.uk/

or even http://www.thissite.co.uk/Whatever.php

I dont want to re-direct the person in any way just show the link as the root of the domain on whatever file is requested in the adirectory folder.

Is this possible? I think myself as pretty resourceful and I have spent the last hour looking for an answer and cant find anything that explains exactly what I want to do.

In hope

Keith

mod_rewrite translates requested URIs (URLs people type into the browser bar, or that they reach by clicking a link) into an underlying file to respond to that request

For example, you can have a request to / (the root of the domain) rewritten to /adirectory/Whatever.php. The URL the user requested is still /, that’s still what’s shown in their browser address bar, but the contents of Whatever.php are returned to the browser.

Is this what you mean?

Hello Dan

Thank you for getting back.

I think I am getting confused about what modrewrite is for then.

basically there is a bunch of files in a directory and I dont want the user to see the name of the directory that they are in. In the example “adirectory” so I though that mod rewrite would display (or mask) the url as coming from the root.

If there is anywhere you can point me, that would help.

Thanks in advance.

Regards

Keith

Well, it’s “masking” adirectory by displaying the contents of Whatever.php at /, a URL that does not include /adirectory. You can do the same for all requests, rewriting them to serve the file by the same name in /adirectory while the URL requested does not include /adirectory.

mod_rewrite won’t change what the user typed or any existing links

So the first question is, what are the users typing or clicking? Or is there no site yet and you’re still planning that?

Hi Dan

The user is clicking a link to a form which is then bouncing from form to form collecting information as it goes so the first page is followed by a clickable link to

http://site.co.uk/directory/step1.php?p=19

then it goes to

http://site.co.uk/directory/step2.php from a headers call in PHP at the end of the form input script then on to

http://site.co.uk/directory/step3.php then to

http://site.co.uk/directory/finish.php

Does that help?

Keith

And you want to get rid of /directory without moving step1, step2, step3 and finish.php?

Write a rewrite rule, that matches a request for /step1.php, /step2.php, /step3.php or /finish.php, and rewrites it to /directory/step1.php, /directory/step2.php, /directory/step3.php and /directory/finish.php

Then update your code so that it uses the URLs without /directory/ when redirecting after each form submit. If your forms still redirect to /directory/ mod_rewrite isn’t going to change that.

Guys,

For this, mod_alias is the correct solution.

Regards,

DK

Not wanting to be too cheeky :blush:

how would I go about that? I have up to now got

RewriteEngine on
RewriteBase /
RewriteRule www.site.co.uk /adirectory/*.php

but I know that there is a lot more black art stuff that needs to go in there. Any pointers would be of great help. Thanks Dan

Keith

Thanks Guys

I will have a look at this tomorrow.

Early start in the morning!

Cheers

kivison,

There are examples on the page linked above.

Regards,

DK