I have seen this question posed everywhere but not with the answers that solved it for me. So I played and played and discovered, da dah, the problem. Let's say you log into newspaper.com/sports and all you see is code. That's because the correct url is newspaper.com/sports.html or sports.htm or sports.php. Chrome and others, because there is no newspaper.com/sports(with no dot.extension) finds the html or htm or php and displays its code instead of the page. You can correct this, if you're using File Manger, by changing your /sports.html to /sports(with no dot.extension), or, better yet, save it as both. It you don't know what File Manager is, just be sure to enter the full URL instead of the quickie and you'll see all the pretty colors and text instead of just the courier type style.

Recommended Answers

All 3 Replies

I'm a little bit confused by what you're saying, but let me try to explain to you how it works:

When the browser request newspaper.com/sports, the WebServer (IIS or Apache or etc) will first see if there's any Rewrite Rules that match /sports.

If there's no rule that match /sports, then the WebServer will think that /sports is an directory (because there's no extension and the WebServer handle each requested file by it's extension, so it knows what and how to treat the file - extensions are related to MIME Type configs and Module Handlers).

If the directory /sports exists, then the WebServer will try to find the default document for that directory (index.html, default.aspx, index.php and etc). If the default document exists (default document configuration and also the physical default doc), then the WebServer will parse this file and return it's content.

If the directory /sports exists but there's no default document, then WebServer will either list the directory contents (if the WebServer is configured to do so) or it'll return the error 403 - 'Directory Listing not Permitted'

Last but not least, if the directory doesn't exists at all the WebServer will return 404 - 'Not Found'.

If you don't know them, rewrite rules make possible /sports to be redirect to /sports.html or even /sports/volley to /sports?id=volley.
Rewrite rules are very usefull. Most sites that have friendly urls use rewrite rules.

Anyway, to help you out you need to show us what 'code' are you seeing instead of the page itself.

What the heck?!?

Thank you AleMonterio. You have expanded my understand and knowledge.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.