Solved

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

Posted on 2014-04-06
8
472 Views
Last Modified: 2014-04-10
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
Comment
Question by:Rowby Goren
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Expert Comment

by:bigeven2002
Comment Utility
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
 
LVL 13

Assisted Solution

by:duncanb7
duncanb7 earned 200 total points
Comment Utility
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
 
LVL 17

Accepted Solution

by:
bigeven2002 earned 300 total points
Comment Utility
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
 
LVL 9

Author Comment

by:Rowby Goren
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 13

Expert Comment

by:duncanb7
Comment Utility
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
 
LVL 17

Assisted Solution

by:bigeven2002
bigeven2002 earned 300 total points
Comment Utility
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
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
 
LVL 9

Author Closing Comment

by:Rowby Goren
Comment Utility
Hi

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

Rowby
(And thanks, Ray too!)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now