Solved

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

Posted on 2014-04-06
8
481 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
ID: 39981612
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
ID: 39981623
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
ID: 39981632
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Author Comment

by:Rowby Goren
ID: 39981638
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
 
LVL 13

Expert Comment

by:duncanb7
ID: 39981645
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
ID: 39981658
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 109

Expert Comment

by:Ray Paseur
ID: 39981899
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
ID: 39992318
Hi

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

Rowby
(And thanks, Ray too!)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

820 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