Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Mod_rewrite

 

 


Glasairmell
User

Feb 16, 2008, 1:52 AM

Post #1 of 4 (381 views)
Shortcut
Mod_rewrite Can't Post

Hi Dave, Would you please post and example of how you did a mod rewrite so a viewer file that shows as:

yourwebsite.com/viewer.php/1/page.php

becomes:

yourwebsite.com/viewer/1/page.php

of course I would choose another name other then "viewer" ... just using that to keep things clear.

Also, can one eliminate the "num" call from the url so it ends up as:

Yourwebsite.com/viewer/page.php

I would really like to replace the "1,2,3 etc" with a directory name so the url ends up like:

yourwebsite.com/viewer/whatido/page.php

I know how to work with your viewerfunction.php file, I am just not clear how dependent the program is on the "num" call for the url.


Thanks!


Glasairmell
User

Feb 17, 2008, 11:53 AM

Post #2 of 4 (321 views)
Shortcut
Re: [Glasairmell] Mod_rewrite [In reply to] Can't Post

This is what I ended up using for my specific application.

##################### REWRITE RULES #####################

Options +FollowSymlinks

RewriteEngine On
RewriteBase /

RewriteRule ^/?([^/]*)/([0-9]*)/?([^/]*)$ $1.php?$2 [L]


Dave
Staff / Moderator


Feb 18, 2008, 10:38 AM

Post #3 of 4 (302 views)
Shortcut
Re: [Glasairmell] Mod_rewrite [In reply to] Can't Post

Thanks for posting that.

I haven't actually done a lot with mod_rewrite (other than copying and pasting other code) so I'll use that as a base when exploring it more.

You can drop the number and lookup records by something else. It just requires a bit of custom PHP and MySQL. Basically you just create a field in the editor called 'filename' (or whatever you like), make it unique, and query that in the where clause option like this:

$options['where'] = 'filename = "/whatido/page.php"';

You just need a little PHP code to pull that part out of the url, escape it, and then put it in the where clause. Try this in your page viewer code.


Code
$escapedFilename  = escapeMysqlString( @$_SERVER['PATH_INFO'] ); 
$options['where'] = "filename = '$escapedFilename'";


Test it out by adding: print $options['where']; after to make sure it's printing the right thing.

Hope that helps! Let me know how it goes.

Dave Edis - Senior Developer
interactivetools.com


Glasairmell
User

Feb 19, 2008, 10:00 AM

Post #4 of 4 (292 views)
Shortcut
Re: [Dave] Mod_rewrite [In reply to] Can't Post

Thanks!

Here is a good referance for your mod_rewrite.

http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.pdf

Mell

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4