Link to home
Start Free TrialLog in
Avatar of Rowby Goren
Rowby GorenFlag for United States of America

asked on

Htaccess - directing a non-existant file to an existing file

Hello

I have some pages on my website that other sites are pointing to.

Can I create an htaccess file that points these non-existant pages to existing pages on the site.

If so please give me some examples on how to do this.

Or do the original pages need to exist?

Thanks!

Rowby
Avatar of bigeven2002
bigeven2002
Flag of United States of America image

Hello,

In the ,htaccess file, use a Redirect to direct users to the correct pages.
Redirect /path/to/badfile.php http://www.domain.com/path/to/goodfile.php

Open in new window


Or if both files are supposedly in the same parent directory:
Redirect /badfile.php /goodfile.php

Open in new window


Or if both are in the same subdirectory:
Redirect /dir/badfile.php /dir/goodfile.php

Open in new window

SOLUTION
Avatar of duncanb7
duncanb7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rowby Goren

ASKER

Hi Duncan and bigeven2002  (will be splitting points)

So in this case, it's not a "301' redirect.....

I will also check your link, Duncan.

Thanks

Rowby
Avatar of duncanb7
duncanb7

You can find more "redirect .htacess" in internet such as
http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F  (the site is from hosting service company)
And  it seems your question is not just redirect in .htaccess since you mentioned non-existant and existant file. If non-existant file,  what we can do besides using link file ? Link file is also a file. Could you write more about it.

Duncan
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No points for this please.

301 is used to tell the user agent that the redirection is permanent -- never visit this URL again, even when asked.  Instead go to the redirection URL.

Best to all, over and out, ~Ray
Hi

Thanks for your help.  Got it working, taking in consideration all of your solutions.

Rowby
(And thanks, Ray too!)