Join 132,666 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,152 people online right now. Registration is fast and FREE... Join Now!
I am trying to make a clean URL script for my website and I have coded the base of what I need but I have come accross 3 error and I don't know how to fix them. Here are my errors:
Notice: Undefined index: PATH_INFO in /homepages/cleanurl.php5 on line 57 Notice: Undefined offset: 0 in /homepages/cleanurl.php5 on line 61 Notice: Undefined offset: 1 in /homepages/cleanurl.php5 on line 62
I have put in my code where the errors are. The beginning of the line with an error has: '{{line#}}'
CODE
/* |--------------------------------------------------------------- | Clean URL's |--------------------------------------------------------------- | | Allows the script to make make clean URL's. | | Example: | http://www.domain.com/index.php/pages/home | */ {{57}} $path_info = $_SERVER['PATH_INFO']; $clean_url = explode('/',$path_info); array_shift($clean_url);
{{61}} $GLOBALS['action'] = $clean_url[0]; // This is our action {{62}} $GLOBALS['name'] = $clean_url[1]; // This is our action's name
RewriteEngine On RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?u=$1
Now with this instead of typing [http://www.domain.com/index.php/pages/home....php?u=whatever (or whatever you're trying to change to a clean URL) you can type http://www.domain.com/index.php/pages/home and both will take you to the same place.
Remember this is done in .htaccess file
This post has been edited by PsychoCoder: 7 Aug, 2007 - 11:25 AM
I don't want to use mod_rewrite!!!! I want to use PHP!!!
Please help me fix the errors in my script, Please. I don't want to use mod_rewrite. I don't need to hear about how to use something I don't want to use. I know how to use it but don't want to for this script, it just isn't going to work for this script.
Sorry, I usually don't get mad but if I wanted to use mod_rewrite I would of used one of the ten thousand tutorials on the internet.
Can someone please help me with my script and not trying to pull me into something I don't want to use?
I don't want to use mod_rewrite!!!! I want to use PHP!!!
Please help me fix the errors in my script, Please. I don't want to use mod_rewrite. I don't need to hear about how to use something I don't want to use. I know how to use it but don't want to for this script, it just isn't going to work for this script.
Sorry, I usually don't get mad but if I wanted to use mod_rewrite I would of used one of the ten thousand tutorials on the internet.
Can someone please help me with my script and not trying to pull me into something I don't want to use?
Theres no reason to be an ass! You asked for help, I fucking offered it! mod_rewrite IS THE BEST SOLUTION for what you want.
<edit>Its quite obvious your idea isn't working, otherwise you wouldn't be here asking for help!</edit>
This post has been edited by PsychoCoder: 7 Aug, 2007 - 12:32 PM
I do thank you for the help, but it is not what I am looking for. I am sorry I have been up for about 40 hours working on my program and really just wanted some help. I know that mod_rewrite would be the best answer but I just want to do it in PHP instead. I would like some help fixing the errors in my script. I am sorry that I got mad.
And I offered you a clean, efficient (actually best solution for your problem) and you jumped down my throat so find your own goddamn solution! If you actually "knew" mod_rewrite you'd KNOW its the best solution for your problem. So have fun finding a solution
Thanks for the help? I am sorry. Is there anyone that understands what I want to do that can help? I really just need my errors fixed and I don't know what is wrong with my code other then what the errors gave me and I don't know how to fix it.
I have the logic that will get the correct page based on the variables the script I posted returns. If anyone wants to see that logic just ask and I will post it, but it hasn't returned any errors when I tested it and it seems almost independent from what I posted.