Current location: Hot Scripts Forums » Programming Languages » PHP » How to create url like Code Ignetor ?


How to create url like Code Ignetor ?

Reply
  #1 (permalink)  
Old 03-20-09, 02:26 AM
Dommy Dommy is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Smile How to create url like Code Ignetor ?

Hi,
I just wanna to create url like Code Ignetor ( or Ruby on Rails, Akelos ) and not using .htaccess file? Please help me ?

Sorry for poor English.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-20-09, 05:10 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
You could do something like this, but you don't get the value of .htaccess

Code:
index.php?pathname/subpath/sub-subpath
Using either the $_GET or $_REQUEST arrays.
You can then parse the first (and only in the case of the $_GET) array index name contained therein.

i.e.
Code:
 // index.php

<?php

print '<pre>';
print_r($_REQUEST); // Will also contain whatever session variables that are set...
print_r($_GET);
print '</Pre>';
Code:
 // output of index.php
Array // Output of $_REQUEST
(
    [pathname/subpath/sub-subpath] => 
    [SESSvariables_maybe_set] => 
)
Array  // Output of $_GET
(
    [pathname/subpath/sub-subpath] => 
)
Reply With Quote
  #3 (permalink)  
Old 03-21-09, 08:21 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
If you use that method, also look into grabbing $_SERVER['QUERY_STRING']

Another way you could use is having index.php itself act as the base directory:
Code:
/index.php/pathname/subpath/sub-subpath
PHP Code:

echo $_SERVER['REQUEST_URI'] ; // /index.php/pathname/subpath/sub-subpath 

Then with some manipulation:
PHP Code:

$uri  $_SERVER['REQUEST_URI'];
$file '/' strtolowerbasename__FILE__ ) );
$base strtolowersubstr$uri0strlen$file ) ) );

if ( 
$uri !== $file && $file === $base )
{
    
$uri substr$uristrlen$file ) );
}

// http://localhost/
echo $uri// -> /

// http://localhost/index.php
echo $uri// -> /index.php

// http://localhost/index.php/
echo $uri// -> /

// http://localhost/index.php/some/path/name
echo $uri// -> /some/path/name 
__________________
The toxic ZCE

Last edited by Keith; 03-21-09 at 08:26 AM.
Reply With Quote
  #4 (permalink)  
Old 03-22-09, 12:26 AM
Dommy Dommy is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for all advise. It help me.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] LF Code for url to button IndyTim JavaScript 2 03-10-08 10:47 AM
convert problem jonnekke PHP 12 02-26-08 02:55 AM
Read url and create links tefc2006 PHP 1 12-03-06 02:02 PM
How do I create a form that, when submitted, a new page takes on its URL? NormanTang PHP 10 09-16-05 01:16 PM
How do I create a form that, when submitted, a new page takes on its URL? NormanTang HTML/XHTML/XML 2 09-09-05 10:53 AM


All times are GMT -5. The time now is 08:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.