How to remove .index.html from URL? - html

I would like to know is it possible to remove index.html, info.html from the URL?
Also, what to add in
Start page
to make a start page like facebook.com. (Without facebook.com/index.html(php)?

You use this:
Start page
And you can set rewrite rules and stuff depending on server and access.
Wanna learn more, google for apache and rewrite rules and .htaccess if you are on an apache server. Else you are probably on a nginx server.

Related

Redirect if there is no index file found

Is there a way in my localhost (Laragon) to change the page that you see when there is no index from this
to this
I have made this page myself but now i want make all the files like this, this is just a simple index.php file but i don't want to manually add this file when there is no index file
Wich file do i have to make or edit to make this?
Laragon web server is Apache, so you'll need to configure Apache to use a custom "DirectoryIndex".
See http://httpd.apache.org/docs/2.2/mod/mod_dir.html#DirectoryIndex.

When a URL ends in a slash, does that mean they're using an index file?

My spider sense tells me that they're not using a folder with an index file for each page, like apple's for example where http://www.apple.com/iphone/ ends in a slash. I've seen it also at other personal sites. How are they able to do it?
They use rewrite rules in their .htaccess files, so /iphone/ could be a folder, or it could be a controller/action of their web application.
Check this link for more info:
http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

Is it possible to change the url of a static .html without changing the name of the file?

I would like to know if there is a way to change the url of a .html file without changing the name of the file. Eg. if I have a website with a page called 1.html, is there a way to make it appear as mypagename.html to visitors and crawlers?
This is called URL-rewriting. URL-rewriting implementation differs between different platforms. So, you have to state your server application (e.g. Apache, IIS etc.).
If you're running on *nix, it may be easiest to just use a link (soft may require a configuration change, hard will require you to remember that both names refer to the same file).
Note on enabling soft links: https://serverfault.com/questions/244592/followsymlinks-on-apache-why-is-it-a-security-risk
You could use the HTML5 History API to push a new, possibly fake, address. I wouldn't suggest it tough.
https://github.com/browserstate/History.js/
Yes there is, but your host must provide URL rewriting. If you're on a Apache server look for .htaccess capabilities and mod_rewrite's RewriteRule directive

301 Redirect directly in HTML file with nginx

I wonder if 301 redirect is possible in an exclusively html static nginx server?
I know that normally it is not possible to make redirect work in html only. In apache server, it is possible to make redirect by using .htaccess. I wonder if there is a similar way of doing this in nginx too?
Have you tried this? I remember testing this quite a while back and it worked for me. Let me know if you are able to get it working or I'll test it on my end

web-development: how do you usually handle the "under costruction" page"?

I was wondering what's the best way to switch a website to a temporary "under costruction" page and switch it back to the new version.
For example, in a website, my customer decided to switch from Joomla to Drupal and I had to create a subfolder for the new CMS, and then move all the content to the root folder.
1) Moving all the content back to the root folder always create some problems with file permissions, links, etc...
2) Creating a rewrite rule in .htaccess or forward with php is not a solution because another url is shown including the top folder.
3) Many host services do not allow to change the root directory, so this is not an option since I don't have access to apache config file.
Thanks
Update: I can maybe forward only the domain (i.e. www.example.com) and leave the ip on the root folder (i.e. 123.24.214.22), so the access is finally different for me and other people? Can I do this in .htaccess file ?
One thing to consider is you don't want search engines to cache your under construction page - and you also don't want them to drop your homepage from the search index either (Hence just adding a "noindex" meta tag isn't the perfect solution).
A good way to deal with this is do a 302 redirect (temporarily moved) from your homepage to your under construction page - that way the search engine does not cache your homepage as an under construction page, does not index your under construction page (assuming it has a NOINDEX meta tag), and does not drop your homepage from the search index either.
One way would be the use of an include on your template page.
When you want the construction page to show, you set a redirect in the include to take all traffic to the construction page.
When you are done your remove the redirect.
What about hijacking your index.php file?
Something simple, along the lines of
<?php
if (SITE_OFFLINE)
include 'under_construction.html';
else
//normal content of your index page
?>
where you would naturally define SITE_OFFLINE in an appropriate place for your needs.
What I did when I used PHP for websites was to configure Apache to direct all requests to a front controller. You then would have full access to all requests no matter where they are pointing to. Then in your front controller (PHP file, static html file, etc.), you would do whatever you need to do there.
I believe you need to configure pathinfo in Apache and some other settings, it has been about 3 years since I have used that approach. But, this approach is also good for developing your own CMS or application so that you have full control over security.
You have to do something similar to this:
http://www.phpwact.org/pattern/front_controller
I am looking for more details, I know my configuration had more to it than that.
This is part of what I'm looking for too:
http://httpd.apache.org/docs/2.0/mod/core.html
Enabling path_info passes path information to the script, so all requests now go through a single point of entry. Let me find my configuration, I know vaguely how this works, but I'm sure it looks like a lot of hand waving.
Also, keep in mind that because all requests are going through this single PHP file, you are responsible for serving images, JavaScript, CSS, etc. So, if a requests is coming in for /css/default.css, that will go through your php script (index.php, most likely), then you'll need to determine how to handle the request. Serving static files is trivial, but it is a little more work.
If you don't want to go that route, you could possibly do something with mod_rewrite so that it only looks for .html, .htm pages or however you have your site configured. For me, I don't do extensions, so that made my regex a little more difficult. I also wanted to secure access to all files. The path_info was the solution for me, but if you don't need that granularity, then writing a front controller might be a bit too much work.
Walter