Jul 3, 2009

Php Mod Rewrite Tutorial - Simple tutorial

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Php Mod Rewrite Tutorial - Simple tutorial

unLog!c
REQUIRED: Internet server (Apache 1.3.33 recomended), php, basic skills with .htaccess

Mod rewrite is cool Apache option, it helps you to make your site URLs simple and clean... also it is perfect for search engines...


This is mod rewrite, it replaces :
CODE
site.com/index.php?include=files?ID=45


with:
CODE
site.com/files/45


so lets get startet, open notepad, enter this in it:
CODE
RewriteEngine On // - you are starting rewrite mod :)
RewriteBase / // - you set the rewrite base
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2 // and rule:
// ^(.+) - text ONLY
// ([0-9]+) - numbers ONLY


DON'T INCLUDE MY COMMENTS IN REAL HTACCESS!!

CODE
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2




save it as: .htaccess and upload it to the root directory...

and that's all work smile.gif

IMPORTANT:
there is problem with browsers, browsers don't recognize that folders you tiped are not real so there is problem with images and css style, so just include apsoluthe path
this is only basic, if you realy wanna do some serious work with mod rewrite visit:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html

as you can see this is also static URL, but can we be shure?! wink.gif



btw. sorry for not so great spelling wink.gif

 

 

 


Comment/Reply (w/o sign-up)

iGuest-A.S.Pardeshi
How to do this mod_rewrite tutorial
Php Mod Rewrite Tutorial

I am in the business of outsourcing. I have around 100 branded products for taking outsourced jobs. I have a list of the branded products keywords.

I have to design a page maybe in html or php whatever you may think fit with contents about outsourcing. Let us assume this is the below paragraph:-

"We are doing outsourcing for the product xxxx since last many years. We have all the resources to manage the outsourcing of the product xxxx. So if you have to outsource the requirement for xxxx, kindly contact us with the details"


Now if you take my product list in a text file of 100 product list. I want xxxx in the above paragraph to be replaced by the product keyword typed in search engine.

Now let us take for example I have product "H*P La*se*rjet 10*20" suppose if anybody type in the search engine the above keyword and if that keyword is in my list then the xxxx in the above paragraph in yellow should get replaced with the keyword "H*P La*se*rjet 10*20" and presented to the search engine. The output will look similar to the one given below

"We are doing outsourcing for the product H*P La*se*rjet 10*20 since last many years. We have all the resources to manage the outsourcing of the product H*P La*se*rjet 10*20. So if you have to outsource the requirement for H*P La*se*rjet 10*20, kindly contact us with the details"



Please help me know how to do it ? Any help from SEO Experts is highly appreciated.

Kind Regards

-reply by A.S.Pardeshi

ADMIN
================

You are basically talking about DYNAMIC content.

You will need a PHP engine which fetches WORDS out from database.

These words are replaced on the fly and the web-page is shown to your user.

MOD-REWRITE on the other hand can be used to GENERATE different pages. So, instead of writing 100 static pages, you can use MOD-rewrite to identify the requested page from URL and calling your PHP script with appropriate URL-encoded variables. :-)

This Page at Trap17.com uses MOD_REWRITE engine.

-Shree (Trap17.com)

 

 

 


Comment/Reply (w/o sign-up)

optiplex
dude, thats awesome!

This will make the url much cleaner ohmy.gif, with a simple .htaccess file and regular expression!
Now I know how those site do that ^^ And its funny

Thanks!

Comment/Reply (w/o sign-up)

csp4.0
QUOTE(unLog!c @ Apr 14 2005, 04:38 AM) *
REQUIRED: Internet server (Apache 1.3.33 recomended), php, basic skills with .htaccess

Mod rewrite is cool Apache option, it helps you to make your site URLs simple and clean... also it is perfect for search engines...


This is mod rewrite, it replaces :
CODE
site.com/index.php?include=files?ID=45


with:
CODE
site.com/files/45


so lets get startet, open notepad, enter this in it:
CODE
RewriteEngine On // - you are starting rewrite mod :)
RewriteBase / // - you set the rewrite base
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2 // and rule:
// ^(.+) - text ONLY
// ([0-9]+) - numbers ONLY


DON'T INCLUDE MY COMMENTS IN REAL HTACCESS!!

CODE
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2




save it as: .htaccess and upload it to the root directory...

and that's all work

IMPORTANT: there is problem with browsers, browsers don't recognize that folders you tiped are not real so there is problem with images and css style, so just include apsoluthe path
this is only basic, if you realy wanna do some serious work with mod rewrite visit:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html

as you can see this is also static URL, but can we be shure?!



btw. sorry for not so great spelling



So... just to make this clearer, (I'm not really good at .htaccess and only know some basic commands) if I were to make this work for multiple files (i.e. if I were to use phpBB3, and wanted to change the "viewtopic.php", and "viewforum.php" ones to something cleaner I would change the code to something like this:?

CODE
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ viewtopic.php?f=*
RewriteRule ^(.+)/([0-9]+)/?$ viewforum.php?f=*


Would that work? Does it even support wildcards? Or do I have to spend time installing a SEO modification?

Comment/Reply (w/o sign-up)

(G)Author Name - e.g. John, Mike
Hi,

 if you don't want to use absolute paths for elements, which are placed in BODY (like IMG). Than simply write the BASE-Element between <head> and </head>:

<base href="http://www.Mywebsite.Com/">

If you do, you are able to use relative paths for all content. All files linked in HEAD (such as CSS-, JavaScript-Files, Favicon) have to have absolute paths, though.

 

Regards from Berlin,

Freddy


Comment/Reply (w/o sign-up)

(G)Harry
Please Submit index.php file for Example
Php Mod Rewrite Tutorial

.Httaccess

----------------------------------------------------------

RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ index.Php?include=$1&ID=$2

----------------------------------------------------------

index.Php

---------------------------------------------------------- 

????????

????????

---------------------------------------------------------- 

Please submit index.Php file for example the tutorial. Thanks

-reply by Harry

 


Comment/Reply (w/o sign-up)

fadillzzz
QUOTE (unLog!c @ Apr 14 2005, 01:38 AM) *
REQUIRED: Internet server (Apache 1.3.33 recomended), php, basic skills with .htaccess

Mod rewrite is cool Apache option, it helps you to make your site URLs simple and clean... also it is perfect for search engines...


This is mod rewrite, it replaces :
CODE
site.com/index.php?include=files?ID=45


with:
CODE
site.com/files/45


so lets get startet, open notepad, enter this in it:
CODE
RewriteEngine On // - you are starting rewrite mod :)
RewriteBase / // - you set the rewrite base
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2 // and rule:
// ^(.+) - text ONLY
// ([0-9]+) - numbers ONLY


DON'T INCLUDE MY COMMENTS IN REAL HTACCESS!!

CODE
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2




save it as: .htaccess and upload it to the root directory...

and that's all work

IMPORTANT: there is problem with browsers, browsers don't recognize that folders you tiped are not real so there is problem with images and css style, so just include apsoluthe path
this is only basic, if you realy wanna do some serious work with mod rewrite visit:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html

as you can see this is also static URL, but can we be shure?!



btw. sorry for not so great spelling

thanks for the tutorial
but what should i put in the .htaccess if i want to rewrite the url into site.com/somedir/somefile.html

Comment/Reply (w/o sign-up)

fuzzon
how can i change this url www.domain.com/downloads/index.php?&direction=0&order=&directory=myhome to this www.domain.com/downloads/myhome/ please tell me

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Php Mod Rewrite


    Looking for php, mod, rewrite, simple

Searching Video's for php, mod, rewrite, simple
See Also,
advertisement


Php Mod Rewrite Tutorial - Simple tutorial

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com