Content Rewrite

Content Rewriter

Disclaimer Article Rewriter

FreeContentRewrite.com is not responsible for any abuse of this free information. Use this free online rewriter resource only for rewriting your OWN content, articles, text, lyrics or other content. Reproduction of protected content as defined in the copyright laws requires a written permission of the copyright owner! Let us now rewrite!

Rewrite URL with MOD rewrite

Mod Rewrite Basis

Rewriting your URL’s is a way of rewriting your website content for both search engine purposes and visitor usability. To explain the basis of mod_rewrite modules on your website, I take the example of rewriting old urls to new logical addresses. For webmaster rookies; You start with rewriting unreadable, not understandable URL’s to readable, logic, easy to understand website addresses. But before we start with that, we first take a look at how to use the mod_rewrite module itself.

First of all we must configure the Apache server so it understands which url rewriting services must be processed. To configure the Apache server for mod / url rewriting you have two options; set up a.htaccess file in the root of your webroot or adjust the settings in the httpd.conf. file on your server. Since most webhosts will not give access to the httpd.conf file, I will focus on mod_rewrite code examples with a .htaccess file. The beginning of each rewrite task is declaring the rewrite
engine and turning it on.

So far we add the next to our .htaccess:

Code
RewriteEngine On

Now the rewrite engine is turned on we can start rewriting url’s to more search engine friendly ones by adding the code below. Example: Forwarding / redirecting URL’s

Code
RewriteEngine On
RewriteBase /
RewriteRule old_url_rewrite_seo.php new_url_rewrite_seo.php

This is the easiest example of using the mod_rewrite module for Apache servers. First we seen integrating the rewrite engine with the RewriteEngine On statement. Then we used the RewriteBase/ to indicate that we us the root of our website as a startingpoint for any URL rewrite task. The most important code line from this example is the last
one. RewriteRule statement indicates which exact rewrite action must be taken. In this case rewriting the first old_url_rewrite_seo.php file to a logical copy new_url_rewrite_seo.php.

The syntax of RewriteRule statements are always as follow:

Code
RewriteRule PATTERN DESTINATION [FLAGS]

In the second example was “old_url_rewrite_seo.php” therefore the value for PATTERN and “new_url_rewrite_seo.php” the value for DESTINATION. Concerning the optional FLAGS that can be configured we take a look at those in a couple of minutes. The best cheat sheet for the use of Mod Rewrite is developed by LoveJackDaniels.com. In the rest of this article I will refer regularly to this sheet.

Fot the PATTERN in the mod rewrite syntax it is also possible to use a regular expression. This is an useful example if you want several files to match at the same. Example: Redirect Directory Pages URL

Code
RewriteEngine On
RewriteBase /
RewriteRule ^old_map/(.*)$ new_map/$1

This example of RewriteRule shows that of all files and child directories in the old_map the path is rewritten and old_map is replaced by new_map. Resulting in that the content from the new map is loaded while the url still refers to the old map. This is very useful after renaming a directory on your webserver.Search engine friendly urls

The mod_rewrite module is perfectly suitable for making search engine friendly urls for your website. Beside the fact that such types of SEO rewritten urls are better to interpret by search engines, they also look a lot more friendly and understandable to us visitors. This helps the coordination and usability of your website. SEO URL’s? What is a search engine friendly url? That is a question which I will answer by means of an example. We all have seen url’s like these ones:

Code
http://www.url-rewrite.com/rewriter/tutorials.php?id=10&page=4&replies=20

The Search engine friendly version of this url could be as followed:

Code
http://www.url-rewrite.com/rewriter//tutorials/10/4/20/

The looks of this url improves already by just a simple statement but can be optimized way more. Besides your URL looks good it can be understood better by search engines resulting in well indexed website content with more organic visitors/traffic.

Optimizing your website with the rewrite_mod module is a must have for every webmaster because it works great when monetizing your website. Before we can earn some dollar we take a closer look to a simple example. Search Engine Friendly URL by mod_rewrite

Code
RewriteEngine On
RewriteBase /
RewriteRule ^tutorials/(.*)/$ tutorials.php?id=$1

This example shows how the URL ‘http://www.url-rewrite.com/rewriter/tutorials/12/‘ is rewritten to
’http://www.url-rewrite.com/rewriter/tutorials.php?id=12′
It isn’t necessary the use the GET variable id in the url its enough just declaring like this. But what if we have more than one GET variables? Check the next example. Say we want to make of optimize all below URL to search engine friendly ones;

  • http://www.url-rewrite.com/rewriter/tutorials.php?id=10&page=4&replies=20
  • http://www.url-rewrite.com/rewriter/tutorials.php?id=10&page=4
  • http://www.url-rewrite.com/rewriter/tutorials.php?id=10

The last URL we cover with code example 4 but the rest needs advance SEO coding.
Example: More than one GET variables

Code

The order of the URL in this example is not readom chosen, it is by purpose, also in the .htaccess file this URL order needs to be copied. Take notice of the fact that the URL with the most GET variables needs to be first in the order and than the ones with less variables. The url with many GET variables also stands variables to the regular expression for one with less variables and in this way preventing you executing the wrong RewriteRule.

In this example the Apache server will run the rewriting tasks as soon as rule matches the url. After the positive match the rewrite rule is processed and the Apache server will go to the next one. In regular expression we see the next syntax (. *), this is an expression which matches all content and url’s. It is an wildcard. Furthermore we see some coding like $1, $2 and $3. These expressions refer to first, second and third child node of the array. This was an simple overview of rewriting your URL’s with MOD_REWRITE on a Apache Server. More detailed information and example coding can be found on IloveJackDaniels.com.

Common search results:
mod rewrite, rewrite mod, rewrite url, rewrite address, apache definitive definitive guide guide mod rewrite, apache mod rewrite, mod rewrite, mod rewrite help, rewrite url

Rate and Submit us These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Comments

One Response to “Rewrite URL with MOD rewrite”

  1. shereen on January 17th, 2008 11:11 am

    complete services

Leave a Reply




Copyright © 2007 Online Free Content Rewrite & Free article rewriting service & India University