Solved

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

Posted on 2014-04-06
8
478 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

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.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

777 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