Ninjakreborn Posted February 12, 2007 Share Posted February 12, 2007 What options are available to write url's. After finally looking up mod_rewrite, it's not something you can do with PHP. It is something done in apache, something like codeignitor does it on all systems, and I am unaware of how they do it, I can't find anything about it. I also know htaccess is another option, but not all server's support or allow htaccess file's so that is another thing that won't work. Is there a way using just php to rewrite all incoming url's and make them segment based? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 12, 2007 Share Posted February 12, 2007 As far as I know, only web servers can rewrite URLs. You cannot have the end product (a PHP page) rewrite the path to itself. You could probably write your own web server in PHP, thus using PHP to rewrite the URLs, but that would just be silly. Did you go through the docs? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted February 12, 2007 Author Share Posted February 12, 2007 Ok, that should be everything I need thanks. SOLVED Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted February 12, 2007 Share Posted February 12, 2007 if it's the CI/Cake/Wikipedia, etc, etc way you like then it's very simple. all you need is an apache server and a htaccess file. My framework uses similar to this in its .htaccess which is located in my web root: RewriteEngine on RewriteCond $1 !^(favicon\.ico|index\.php|js|css|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] which basically says: if it's not my favicon.ico, index.php, js folder, css folder or my robots.txt file, then throw it through my web root's index.php. i then pick up the segments using $_SERVER['PATH_INFO'] which gives me a single string containing everything after the domain name. without mod_rewrite, you can get a similar effect using a url like: http://www.mydomain.com/index.php/controller/action/id using mod_rewrite for this example has two benefits here though: 1, removes the need to have index.php in the URL 2, restricts access to ANY file/dir you dont specify in your .htaccess file automatically. there are lots of ways of structuring the URI though. take a look at the URI of this forum page: index.php/topic,126674.0.html if you ran that on your own server, then a line in your index.php such as: echo $_SERVER['PATH_INFO'] would output: /topic,126674.0.html Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 12, 2007 Share Posted February 12, 2007 Man. Seriously. Stop posting all your questions in the misc. forum!! Post them in the appropriate forum. mod_rewrite goes into Apache. Cron goes into Linux. etc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.