I don't want to show the HTML file name as the home page, such as stackoverflow.com, instead of stackoverflow.com/home - html

Using htaccess I was able to hide the file extensions, making it /home instead of /home.html. However, for the homepage, I would like to hide the file name altogether, for example stackoverflow.com, instead of stackoverflow.com/home. How do I achieve this?

You'll need to look into using a rewrite engine.
From Wikipedia:
A rewrite engine is software that
modifies a web URL's appearance (URL
rewriting). Rewritten URLs (sometimes
known as short or fancy URLs) are used
to provide shorter and more
relevant-looking links to web pages.
The technique adds a degree of
separation between the files used to
generate a web page and the URL that
is presented to the world.
More specifically, it depends on the web server you're using. Here's a guide to URL Rewriting in Apache, for example.

See DirectoryIndex:
DirectoryIndex home.html

Name the home page index.html, then it will display as the default for / (given normal apache rules)

Related

How to mask a URL via HTML or .htaccess

I am setting up a website that I want no one to know the URL for. For example, I send them a link that actually goes to the page, but the URL in the bar at the top has a completely different URL that I don't own. I'm not sure if this can be done in PHP, HTML, or the .htaccess file.
This is not possible, unless
you control the systems of the visitors (then you could, for example, change their DNS servers), or
you find and exploit a bug in the browser/system.
You can make a link anchor text look like it leads to a specific domain not under your control, but the real URL will be used in any case. Example: http://wikipedia.org/.

How can I hide the full url of my website?

When I upload my website files to my server and goto my website, i see the index.html at the url bar of the browser. How can I hide this?
http://bakpinar.com/about/about-us.html
I would like it to look like in this example;
http://www.royaltyline.com
as you can see, you only see the website address in the url bar of the browser. And when you click to another page, it doesnt show the .php, .asp or .html extension, just shows the folder name.
To hide the extension shown in the address bar, you have two options.
If you control the server, you can define rules that rewrite the URL based on the one the user is trying to get to. In PHP you can use the .htaccess file to define mod_rewrite rules. For similar features to .htaccess you can install the application request routing module in IIS 7 and above. In IIS (Windows) you can set up default pages that come up when users go to particular sites.
You can also make that all of your pages are accessed through the same page using AJAX, or put all the content on the same page and hide it using CSS and display it with CSS and/or JS.
This is a very high level answer, because the specifics vary greatly from situation to situation.
An easy way to do this, in case someone is still looking, is to use a full-screen iFrame. No matter where on the page your users are, they will always only see the main url. This used to be very popular back in the day, but it was a terrible practise in terms of usability.
<html><head>the stuff</head><body>
<iframe src="http://bakpinar.com/about/about-us.html" width=100% height=100%></iframe></body></html>
Write that into the index.html file at http://www.royaltyline.com
Yes, you can do by javascript.
<script>
window.history.replaceState('','','/');
</script>
It's not actually a folder name. It's rewritten URL.
To do such things you should redirect all requests to one file (index.php for example), then parse URL and basing on its parts, show particular file.
To redirect everything to index.php, use mod_rewrite module of Apache + .htaccess file.
To choose specific file you can implement one of several approaches. It's usually called routing in design patterns.
Completely other approach would be to use AJAX for reloading content. But it's not the way it was made on the website you gave as example.
In general there is a lot of information about routing urls in PHP on the web. Just do some research.
You are effectively looking to rewrite URLs. If your web server is Apache you will be able to use the rewriting module (mod_rewrite) to direct requests to http://bakpinar.com/about/ to http://bakpinar.com/about/about-us.html
If you are not running Apache, most web servers will serve index.html as the default page when requesting a directory, so renaming
about-us.html
to
index.html
and changing incoming links to
/about/about-us.html
to simply
/about/
Will give you the same results.

What does // mean in an <a> tag

I'm writing a web crawler and I'm testing it out by starting at Wikipedia. However, I noticed that many of wikipedia's links are prefaced with //, so the link from wikipedia.org to en.wikipedia.org is a link to //en.wikipedia.org. What exactly does this // mean in practice? Does it say "use whatever scheme you were using before and then redirect to this url?" or does it mean something entirely different?
The link will use protocol (http or https) same as page which contain that link. For example if https://stackoverflow.com/ contain it will directed to https://en.wikipedia.org
It maintains the protocol that is being used for the webpage. HTTP/HTTPS.
It's particulaly useful for external scripts and css tags, in which you don't know in which protocol your site will be working on.
That's why on Google libraries (https://developers.google.com/speed/libraries/devguide#jquery) you have like this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Just while writing this I found a duplicate: Two forward slashes in a url/src/href attribute
Take a look at it.
Yes, it will redirect to that url using the scheme of the current location.
In order for this to work, the resource this url points to must be available in every scheme it's expected to be redirected from (usually, both http and https).
It is protocoll relative url. It keeps http or https.

How to redirect old website pages to new website which has same domain but new html page names?

I'm working on a website which has had all it's page names changed from the older version however it still has the same domain name. All I want to do is re-direct the page links on google searches to the domain and/or redirect the pages to their new page named versions.
I know this can be done with a .htaccess file. But I'm not sure how as I have tried and it's not working.
To tell google that pages have changed their name you should use 301 redirects.
Here is a nice documentation about howto do those: http://httpd.apache.org/docs/current/mod/mod_alias.html#redirectpermanent
Using mod_alias you can also define regex patterns, like for example /(.*)_old.html has to go to /$1_new.html or things like this, by using RedirectMatch.
Make sure that you use permanent redirects, because google pays attention to if you use permanent (301) or just temporary (302) redirects.

Hide the file name in the URL

what is the best method of hiding the file name in the URL from a developers side (who has no control over the server), for example if the site is www.123.co.za/contact.htm - i wan the user to only see www.123.co.za. an example of such can be seen here http://www.groupon.co.za
ways i know of is using one page and dynamically loading page content using ajax
the other is frames
(server options like mod_rewrite i cant use as i dnt have access to or control over the server)
They are using index pages. That means they have a page such as index.html, index.php, or index.aspx, etc. All you have to do is create a directory (for example, 'contact') and put a file named 'index.html' within that directory. Then you can view www.123.co.za/contact/index.html as www.123.co.za/contact. Note that your allowable index page names may vary. If index.* doesn't work for you, contact the host and ask (sometimes it's default.*).
The catch to this method is that your page is now viewable by at lest three URLS (www.123.co.za/contact, www.123.co.za/contact/, www.123.co.za/contact/index.html). This can hurt your site in search engines for you may get penalized for "duplicate" content. You could solve this issue with mod_rewrite but seeing as you can't use that, you can't prevent the aforementioned scenario.