Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Redirect 'Root Directory' to file?
Old 10-06-2011, 09:06 PM Redirect 'Root Directory' to file?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
This may be a dumb question, but I have my reasons

My problem is unexplainable. I'll try my best though, in layman's terms.

So you know when you go to a website, like google.com, and you see their index page? That's the server, showing the index page, because no file was specified. Well, what I want my .htaccess to do is literally redirect the user to a specified file name if none is specified. So if a user accesses http://www.mysite.com/, I want them to be redirected to http://www.mysite.com/index.html.

It's dumb, I know, but my self-written scripts are glitchy that don't like to work well with my website.

TL;DR How do I redirect the top-level address to a specific filename?

Thanks!

-PG
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-07-2011, 01:12 PM Re: Redirect 'Root Directory' to file?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You do NOT!!

You ESPECIALLY do NOT if the filename is also an "index" filename.

Servers already do a "silent" redirect (302 response) if the URI terminates in a trailing slash '/' then search the specified folder for a file in the list of index files specified in httpd.config or .htaccess in the case of Apache or the default document list for IIS, they also do a "silent" redirect to the trailing slash URI version if the requested URI terminates without a file extension and a trailing slash is not present.

So when trying to redirect to a named document that is also in the index file list there's every chance you are going to create a locked loop.

You can redirect FROM an index file to the root of a folder by using THE_REQUEST directive

Also it would be impossible to write a rediect that attempted to match on "index.html" NOT being in the HTTP request as that would try to redirect EVERY request for any filename to the root.
Just in case you didn't know when apache encounters a URL that matches a redirect/rewrite condition it does a second HTTP request which reloads and examines .htaccess again.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-07-2011, 01:19 PM Re: Redirect 'Root Directory' to file?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
I ended up doing something like if(dirname($_SERVER['REQEST_URI'])=='/'){header("Location index.html");}, but I'll just rewrite the JS if it's that big of an issue.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Redirect 'Root Directory' to file?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15877 seconds with 12 queries