Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

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
0
Rowby Goren
Asked:
Rowby Goren
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
bigeven2002Commented:
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

0
 
duncanb7Commented:
If the file is not existing, could you use symbolic link

The other sites point to the symbolic link(non-existing file) on your site  and then go to other or final  file location. The link file is just recording the path of the final file location

Please read these to do file link
http://www.cyberciti.biz/faq/unix-creating-symbolic-link-ln-command/

Could you explain more about  the definition of "non-existant pages" ?

Duncan
0
 
bigeven2002Commented:
Sorry forgot the last part, the original pages do not need to exist.  I tested with my server and entered a non-existent file in the address bar and it redirected without issue.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
Rowby GorenAuthor Commented:
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
0
 
duncanb7Commented:
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
0
 
bigeven2002Commented:
I think 301 is more often used for permanently redirecting an entire site rather than just one page.  It still can be used, it's just optional.  But if you are concerned about SEO, then using 301 may be ideal.

Redirect 301 /dir/badfile.php /dir/goodfile.php

Open in new window

0
 
Ray PaseurCommented:
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
0
 
Rowby GorenAuthor Commented:
Hi

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

Rowby
(And thanks, Ray too!)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now