Jump to content

Recommended Posts

hello i was doing a little google research until i found a website with a tutorial about creating urls without using mod rewrite can someone please explain it to me and give me some example as procedual code and oop? thank you very much for helping me in your spare time.

 

 

<?php

 

// Get the URL relative to the script

$url = $_SERVER['PATH_INFO'];

 

// If for some reason $_SERVER["PATH_INFO"] does not work then

// you could use $_SERVER["REQUEST_URI"] or $_SERVER["PHP_SELF"]

 

// Remove the /index.php/ at the beginning

$url = preg_replace('/^(\/)/','',$url);

 

// Split URL into array

$url = explode('/',$url);

 

// Display array

print_r($url);

 

?>

[/[code=php:0]

Use this:

http://pastebin.com/fc5fee28

 

This allows you to use url's in the format:

http://<domain>/<page>.php[/<module>]/<controller>/<action>/<param1>/<value1>

 

examples:

// module = admin
// controller = users
// action = edit
// id = 1
http://localhost/index.php/admin/users/edit/id/1

// module = default
// controller = register
// action = index
http://localhost/index.php/register

// module = default
// controller = login
// action = index
http://localhost/index.php/login

thank you very much i will have a look on that php file :)

 

Here's an updated version: http://pastebin.com/f12cbc64c

 

Edit: I tested it and I can confirm it works. If you want I can submit you the used code.

 

P.S. This is the correct format:

http://<domain>/<page>.php[/<module>]/<controller>[/<action>[/<param1>/<value1>]]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.