+ Reply to Thread
Results 1 to 7 of 7

Thread: Tutorial Mod_rewrite

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Tutorial Mod_rewrite

    *Note - x10hosting has mod_rewrite enabled.

    Q. What is mod_rewrite?

    A. Mod_Rewite is an apache module for URL manipulation. It can be used to change the appearance of a path to which a file exists.

    Quote Originally Posted by http://httpd.apache.org/docs/mod/mod_rewrite.html
    This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, for instance server variables, environment variables, HTTP headers, time stamps and even external database lookups in various formats can be used to achieve a really granular URL matching.
    Q. Why use Mod_Rewrite?

    A. The most common use for Mod_ewrite is for SEO (Search Engine Optimization). It is used to trick the spider into thinking dynamically created pages are static.

    For example, showthread.php?t=19864 can be displayed as thread19864.html

    A common misunderstanding by people is that it isn't effective due to the fact that dynamically created pages are indexed by search engine spiders anyway. Allthough this is true there are problems concerned with dynamically created pages being indexed, the main problem is that spiders such as the google spider will move away from dynamically created page once their session has ran out to prevent being caught in an infinate loop inside a site.

    Ok, now that those questions are answered. Lets get on to making the correct files.



    Step 1 - Meh

    Read this tutorial

    Step 2 - Creating the rewrite rule
    Getting the rule you want. This is up to you.
    It could be turning /profile.php?user=123456 into 123456.html <-- will be our example for the tutorial.

    Step 3 - Creating a .htaccess file
    Create a .htaccess using notepad. Save the file as .htaccess
    You have to change the save type to All Files

    Step 4 - Turning on Mod_Rewrite
    The first thing we need to do to that file is turn on mod_rewrite. Use this code

    Code:
    RewriteEngine on
    Options +FollowSymLinks
    Step 5 - Creating the rule
    Next add this code to the .htaccess
    *Note if the file you want is in a sub directoy you need to put that in the link.

    Code:
    RewriteRule ^([0-9]+).html$ profile.php?user=$1 [L]
    Code with sub directoy
    Code:
    RewriteRule ^([0-9]+).html$ /forums/profile.php?user=$1 [L]
    Step 6 - Save the file
    Again save the file. Next go to your FTP program and uplod the file into the directory with profile.php



    If all else fails here is a link that will create the code for the .htaccess file

    Mod_Rewrite Generator
    Behind the Secens with Apache's .htaccess

    *if you see any errors tell me. Ether I or a mod will edit. (Mods you can edit this

    I would love to change the world, but they won't give me the source code

  2. #2
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: Tutorial Mod_rewrite

    did you right all that out...

  3. #3
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Tutorial Mod_rewrite

    ya,

    well i actually copied it from another site but i posed it on that site but at 1 point in time i did

    I would love to change the world, but they won't give me the source code

  4. #4
    Brandon Guest

    Re: Tutorial Mod_rewrite

    RewriteEngine on
    Options +FollowSymLinks
    RewriteRule ^([0-9]+).html$ sig.php?name=$1 [L]

    When I go to blah.html I dont get the image I have tried with php too.

  5. #5
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Tutorial Mod_rewrite

    did you try this

    RewriteEngine on
    Options +FollowSymLinks
    RewriteRule ^([0-9]+).png$ sig.php?name=$1 [L]

    also is the .htaccess in the folder you are calling the page from?

    I would love to change the world, but they won't give me the source code

  6. #6
    Brandon Guest

    Re: Tutorial Mod_rewrite

    Not working.

  7. #7
    Brandon Guest

    Re: Tutorial Mod_rewrite


+ Reply to Thread

Similar Threads

  1. A HTML + CSS Basic Tutorial
    By Zenax in forum Tutorials
    Replies: 14
    Last Post: 09-02-2011, 01:42 PM
  2. [PHP] Pages with ids Tutorial
    By nightscream in forum Tutorials
    Replies: 11
    Last Post: 12-14-2007, 06:55 AM
  3. GML Tutorial?
    By Nate_Benton in forum Gamer's Lounge
    Replies: 11
    Last Post: 08-02-2006, 02:33 AM
  4. Network Folder Sharing Tutorial
    By TheJeffsta in forum Computers & Technology
    Replies: 0
    Last Post: 03-31-2006, 02:33 AM
  5. Lighting tutorial
    By Rising in forum Tutorials
    Replies: 12
    Last Post: 02-20-2006, 01:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers