Jul 25, 2008

Php Mod Rewrite Tutorial - Simple tutorial

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

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

 

 

 


Reply

iGuest
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)

 

 

 


Reply

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!

Reply

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?

Reply



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*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php url rewrite - 0.38 hr back. (1)
  2. modrewrite .php?id - 3.00 hr back. (1)
  3. url rewrite cms with php - 3.86 hr back. (1)
  4. rewriting tutorial php - 3.97 hr back. (1)
  5. url rewrite php - 0.22 hr back. (2)
  6. url rewrite sample with php - 4.91 hr back. (1)
  7. php url rewrite - 4.92 hr back. (1)
  8. php get mod rewrite - 5.25 hr back. (1)
  9. mod rewrite images not showing - 14.44 hr back. (1)
  10. php modrewrite - 1.55 hr back. (2)
  11. using php to rewrite urls - 14.88 hr back. (1)
  12. mod rewrite php - 17.00 hr back. (1)
  13. flatpress htaccess mod_rewrite - 22.18 hr back. (1)
  14. php rewrite url - 17.09 hr back. (2)
Similar Topics

Keywords : php mod rewrite


    Looking for php, mod, rewrite, simple

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



Php Mod Rewrite Tutorial - Simple tutorial



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE