Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 17th, 2006, 12:29 PM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 936
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Apache Internal Redirect Help

Hi,

I've been stuck on this problem for about a year now. Say I have a directory named /foo containing HTML files I want to display. How can I internally redirect any requests for files at the root (/) directory to those files in the /foo directory?

For example, if a request is made for http://www.mysite.com/page.html, how can I display the contents of http://www.mysite.com/foo/page.html without changing the URL in the user's browser?

I've tried using .htaccess scripts to internally rewrite any requests, but for some reason this never works for the root directory; I always get a "500 Internal Server Error."

Any help? Thanks.
titaniumdecoy is offline   Reply With Quote
Old Feb 17th, 2006, 2:04 PM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Maybe a directory alias would work? I've never tried one for the root... but have several for other directories...

Edit your httpd.conf and make a directory alias, such as:

Alias /alias/path/ "/real/path/"
 
<Directory "/real/path">
  Options Indexes MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

Then restart Apache...
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Feb 17th, 2006, 2:18 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 936
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I don't have access to an httpd.conf file because I'm sharing hosting. Is there some way to do this in a .htaccess file?
titaniumdecoy is offline   Reply With Quote
Old Feb 17th, 2006, 2:56 PM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
This works for me: In the httpd root directory, make a .htaccess file with the redirection in it...

Redirect /oldfile http://somewhere.com/some/dir/newfile

BUT, it changes the URL in the browser. Not sure off hand how to keep it from changing that.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Feb 17th, 2006, 3:14 PM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 936
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Thanks, although what I'm really looking for is an internal redirect...
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:30 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC