Solved

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

Posted on 2014-04-06
8
495 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 110

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

617 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