Mobile app version of vmapp.org
Login or Join
Kristi941

: Can the subdirectories on a server have their own default pages? I'm trying to structure my site to serve different areas of content, sort of like this one. I'm wondering how they make it

@Kristi941

Posted in: #Subdirectory #WebDevelopment #WebsiteDesign

I'm trying to structure my site to serve different areas of content, sort of like this one. I'm wondering how they make it so subdirectories have their own default pages, for example:
webmasters.stackexchange.com/questions/ask (the URL of the ask page).

It looks like a default page to me since it doesn't end in a file extension, but I don't know how that works. I'm running on an IIS server hosted on GoDaddy and I'm using the ASP.NET Web Pages (SPA) model if that makes a difference.

And if they're not default pages, why do they appear without file extensions?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kristi941

1 Comments

Sorted by latest first Latest Oldest Best

 

@Murphy175

It is very easy to configure a server to hide file extensions by default. On an Apache server for example, it can be done like this:


SOURCE

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ example.com/folder/ [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ example.com/folder/ [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ .php [L]



I assume IIS can be configured to do something similar, but I have never used IIS.

I'm not sure what you mean by "default page" though. If you want an index page to show up without a filename you just need to call it index.php, index.html, or something like that depending on your server setup.

For example www.example.com/ and www.example.com/index.html would be the same thing. When you go to the first URL, without the file name, it just shows you the index file anyway, but hides the file name from the address bar. If you are trying to hide the extension of a file besides the index file, you'll need some sort of re-write rule like above for IIS.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme