Showing posts with label SEO. Show all posts
Showing posts with label SEO. Show all posts

Thursday, February 12, 2009

Automatic and Dynamic Title URLs from Titles using Javascript

This is a handy little javascript snipplet that will convert text in one text field to url friendly text in another.  This is very useful if you're trying to automatically create title URLs from the title of your post.  This helps with search engine optimization by giving you friendly URLs.  Below is the javascript and a test form.  You can copy it all, paste it, and test it.

<html>
<head>
<script type="text/javascript">
function urltitle(title)
{


// Create the url friendly title
var url = title
.toLowerCase() //change everything to lowercase
.replace(/^\s+|\s+$/g, "") //trim leading and trailing spaces
.replace(/[&]+/g, "and") //replace ampersand
.replace(/[#]+/g, "sharp") //replace pound
.replace(/[@]+/g, "at") //replace at
.replace(/[%]+/g, "percent") //replace percent
.replace(/[+]+/g, "plus") //replace plus
.replace(/[-|\s]+/g, "_") //replace spaces and hyphens to underscore
.replace(/[^a-z0-9_]+/g, "") //remove all non-alphanumeric characters except the underscore
.replace(/[_]+/g, "_") //remove duplicate underscores
.replace(/^_+|_+$/g, "") //trim leading and trailing underscores
;
document.getElementById('title_url').value = url;
}
</script>
</head>
<body>


<input type="text" onkeyup="javascript:urltitle(this.value);" />
<input type="text" id="title_url" />


</body>
</html>


As we usually give credits for what we find, this is where we got the original script before modifying it: Rewrite input to friendly URL

Thursday, November 6, 2008

Monday, October 13, 2008

SEO: mod_rewrite and dynamic pages

Search engines don't really like urls that look like http://mysite.com/page.php?id=1&type=23.  Parameters in the URL throw off some search engines and others refuse to index such pages.  To get around this, and still keep your dynamic information, you can do with the mod_rewrite approach with Apache.

This solution is only for the Apache web server.  If you're using another server, such as Windows, you'll need to figure something else out.

The following link details how to use mod_rewrite to have urls that look like http://mysite.com/pages/mypage/mysubpage function like the url at the top.  http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Thursday, September 4, 2008

SEO: Stopping Search Engine Indexing

If you wanted to stop Google from indexing your website (or any other search engine) you can include a robots.txt file on your server.  This file is checked by search engine bots before indexing and they follow whatever rules you put in there.

You can find detailed information on how to write your robots.txt here: http://www.google.com/support/webmasters/bin/answer.py?answer=40360