Jump to content
xisto Community
Sign in to follow this  
unLog!c

Php Mod Rewrite Tutorial Simple tutorial

Recommended Posts

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 :

site.com/index.php?include=files?ID=45
with:

site.com/files/45
so lets get startet, open notepad, enter this in it:

RewriteEngine On // - you are starting rewrite mod :)RewriteBase / // - you set the rewrite baseRewriteRule ^(.+)/([0-9]+)/?$ index.php?include=$1&ID=$2 // and rule:// ^(.+) - text ONLY// ([0-9]+) - numbers ONLY
DON'T INCLUDE MY COMMENTS IN REAL HTACCESS!!

 

RewriteEngine OnRewriteBase /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 :blink:

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

Share this post


Link to post
Share on other sites

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 Xisto.com uses MOD_REWRITE engine.

 

-Shree (Xisto.com)

Share this post


Link to post
Share on other sites

dude, thats awesome!This will make the url much cleaner :), with a simple .htaccess file and regular expression!Now I know how those site do that ^^ And its funnyThanks!

Share this post


Link to post
Share on other sites

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 :

site.com/index.php?include=files?ID=45
with:

site.com/files/45
so lets get startet, open notepad, enter this in it:

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!!

 

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 Posted Image

 

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?! Posted Image

 

 

 

btw. sorry for not so great spelling Posted Image

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:?

 

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?

Share this post


Link to post
Share on other sites
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="https://www.1and1.com/website-builder;>

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

Share this post


Link to post
Share on other sites
Please Submit index.php file for ExamplePhp Mod Rewrite Tutorial

.Httaccess

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

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

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

index.Php

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

????????

????????

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

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

-reply by Harry

 

Share this post


Link to post
Share on other sites

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 :

site.com/index.php?include=files?ID=45

with:

site.com/files/45

so lets get startet, open notepad, enter this in it:

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!!

 

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 Posted Image

 

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?! Posted Image

 

 

 

btw. sorry for not so great spelling Posted Image

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

Share this post


Link to post
Share on other sites
Rewrite imagesPhp Mod Rewrite Tutorial

To solve this problem:

IMPORTANT : there is problem withBrowsers, browsers don't recognize that folders you typed are not realSo there is problem with images and css style, so just includeAbsolute path This is only basic, if you really wanna do some serious work with mod rewrite visit:http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

All you have to do is mod rewrite all your image, css and js folders as well:

RewriteRule ^pictures/images/(.+)?$ images/$1 [NC,L] RewriteRule ^pictures/css/(.+)?$ css/$1 [NC,L]RewriteRule ^pictures/js/(.+)?$ js/$1 [NC,L]RewriteRule ^pictures/php/(.+)?$ php/$1 [NC,L]RewriteRule ^pictures/([0-9]+)?$ pictures.Php?year=$1 [NC,L]

-reply by Chaim

Share this post


Link to post
Share on other sites
for me is not workingPhp Mod Rewrite Tutorial

I have tried many "formulas" to rewritemy urls and nothing works.I am searching the internet from weeks and I feel like going crazy. The it guy says the rewrite mode is enabled but he gave me idiot answers and I can?t count on him.

my urls look like this: http://forums.xisto.com/no_longer_exists/

I have uploaded a .Htaccess file with this code:

ErrorDocument 404 /404page.HtmlOptions +FollowSymLinksRewriteEngine onRewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.Php HTTP/RewriteRule ^index.Php$ http://www.inesp.pt/ [R=301,L] 

I managed to create a 404 error page and to redirect index.Php to root. The problem is that none of the rules I have tried didn?t rewrite my dynamic urls in seo friendly url. If anyone has a bit of time, please take a look at my problem. Thanks

-question by ataraxia

Share this post


Link to post
Share on other sites

Friends i am nikhil yadav and i am hosting a web site on yahoo web hosting server. it does not provides .htaccess file on server, so help me how i write my mod rewrite rules on server and get work done.

Share this post


Link to post
Share on other sites

Friends i am nikhil yadav and i am hosting a web site on yahoo web hosting server. it does not provides .htaccess file on server, so help me how i write my mod rewrite rules on server and get work done.


Nikhil,

For mod rewrite to work, you need an Apache web server. Most web hosting services that use an Apache web server will support .htaccess directives and if yours does not, you might need to contact their support to get them to insert the directives that you require in their configuration file for your site. Some of the directives from their configuration file can be overridden using the .htaccess file and therefore they may have disabled the .htaccess directives feature entirely but that should not stop them from making the setting for your site. Other web servers, such as Microsoft's Internet Information Service does not using a .htaccess file but instead requires you to setup the directives using a Web.config file, which is an XML format file that you can easily edit using Visual Studio or any other XML editor or text editor.

If your web hosting services does refuse to enable the URL rewriting for your site, you may have to find another web hosting provider - Xisto is a good choice because you can earn forum credits by posting on Xisto or one of the other participating forum sites and then order your web hosting packages using solely forum credits.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.