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

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.

Related

Create a link that can later be customized to different URL

I would like to create a link that I can customize later.
For example,
I create a href link in the footer of the website I developed for my client with the URL that forwards to my current Web design website.
In the future, if I have to change my Web design website URL I will just customize that footer link forward destination to another one without having to access the CPanel of my client's website.
Please tell me how is it possible to do. Is this possible to with any link shortener services?
The usual way to do this is to set up a redirect from your old site to your new, with a 301 status code. This is easily done with a simple configuration directive in your web server config.
I doubt if there is any link generator service that let you change the redirection link after generated.
If you will be able to access your previous url, link it with redirection page that will redirect client into your current url.
Or get a free domain that only works as redirection link.

How can i tell google that i have removed the .html from my url?

Hi I have recently removed the '.html' from the end of my url's to make them look more professional which was brilliant. However, now when I see my site on Google the old url which includes the '.html' still appears which produces people with an error page as expected. How can I tell Google that I have new url addresses so that people can visit my site again?
thanks!
Best way to remove .html extensions is by adding it in .htaccess file. This way search engines will "understand" it, but you will not seeing the search result immediately, since search engine crawler, will take some time to update.
And make sure to submit your url in google. If you have google webmaster you will be able to see this process and status of your website more clearly.

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.

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.

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

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)