Jump to content

How To Create/link To Pages In Subdirectories?


NikMac
 Share

Recommended Posts

This is something that should be simple, but it's becoming a pretty big obstacle for me.I want to link to www.example.com/lessons/lessons.html when someone goes to www.example.com/lessons . I put the folder "lessons" into my root folder, and "lessons.html" in the "lessons folder". However, when I link to "<a href="/lessons/lessons.html"> or "<a href="./lessons/lessons.html"> I get a 404 error. What am I doing wrong?Thanks.

Link to comment
Share on other sites

Is there also a copy of lessons.html in the root folder? Perhaps as a mistaken upload? I have found that that can cause problems with mod_rewriting, as the server tries to resolve the document first if it can.

Link to comment
Share on other sites

Yes - it must have been some sort of typo as the link is working now.However, I still don't know how to make "www.example.com/lessons/" link to "/lessons/lessons.html". Right now that just points me to an ftp-like "index of file:///..." page. How do I make this work?Thanks.

Link to comment
Share on other sites

if you are just trying to link to a file within the folder you are working in, all you have to do is just link to the page, i.e. lessons.htmlYou can always just write out the whole url just to be sure, www.example.com/lessons/lessons.html

Edited by thescientist
Link to comment
Share on other sites

if you are just trying to link to a file within the folder you are working in, all you have to do is just link to the page, i.e. lessons.htmlYou can always just write out the whole url just to be sure, www.example.com/lessons/lessons.html
I've figured that bit out - but how do I make it so that when a visitor types "www.example.com/lessons", they are redirected to the lessons.html page, and not an ftp or 404 page?
Link to comment
Share on other sites

When a directory itself is requested, the web server will look for certain files, usually index.html or similar, and display that. If you want lessons.html to appear instead, either rename it index.html, create a symbolic link pointing from index.html to lessons.html, use a URL rewriting module to change lessons/ to lessons/lessons.html, or create a new index.html page that redirects to lessons.html.

Link to comment
Share on other sites

When a directory itself is requested, the web server will look for certain files, usually index.html or similar, and display that. If you want lessons.html to appear instead, either rename it index.html, create a symbolic link pointing from index.html to lessons.html, use a URL rewriting module to change lessons/ to lessons/lessons.html, or create a new index.html page that redirects to lessons.html.
Thanks - what is the best way to go with? Would there be any disadvantages to calling it "index.html" (as then I would have at least two "index.html" pages in my site). How do I create a "symbolic link" or "url rewriting module"? - or make a "new index.html page that redirects to lessons.html".
Link to comment
Share on other sites

Would there be any disadvantages to calling it "index.html" (as then I would have at least two "index.html" pages in my site).
Each directories should have an index page, so that people don't end up seeing the folder listing.
How do I create a "symbolic link" or "url rewriting module"? - or make a "new index.html page that redirects to lessons.html".
You can rewrite the URL using, for example on Apache, mod_rewrite. A symlink is a "virtual" file that really points back to the other one, like a link, and can be created using the ln command (UNIX only).You can redirect server-side or client side, on the server-side you can send a Location: header, e.g. (in PHP)
<?php	header("location:lessons.html");?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...