How to manually create Friendly URLs? (PHP)?

Similar to the 404 handler idea, with a very simple RewriteRule you can easily move the URL rewriting management to PHP, which might be easier for you: RewriteCond %{REQUEST_FILENAME}! -f RewriteCond %{REQUEST_FILENAME}! -d RewriteRule .Rewrite.

Php L In rewrite. Php you have an array of RegEx URL patterns. These can be used to match the current URL (use $_SERVER'REQUEST_URI' ) and hand over parts of the URL to a real file.

The parameters can then just be put into the $_GET array and the correct file can be included As an example, the array could look like this: $rules = array( array( 'articles/view/(0-9+)', 'articles. Php? Id=$1' ), array( 'articles/delete/(0-9+)', 'articles.

Php? Id=$1&action=delete' ), ).

Similar to the 404 handler idea, with a very simple RewriteRule you can easily move the URL rewriting management to PHP, which might be easier for you: RewriteCond %{REQUEST_FILENAME}! -f RewriteCond %{REQUEST_FILENAME}! -d RewriteRule .Rewrite.

Php L In rewrite. Php you have an array of RegEx URL patterns. These can be used to match the current URL (use $_SERVER'REQUEST_URI') and hand over parts of the URL to a real file.

The parameters can then just be put into the $_GET array and the correct file can be included. As an example, the array could look like this: $rules = array( array( 'articles/view/(0-9+)', 'articles. Php?

Id=$1' ), array( 'articles/delete/(0-9+)', 'articles. Php? Id=$1&action=delete' ), ).

I know I'm a bit late, but the reason I'm not a fan of this style is that it seems like the exact same thing as the mod_rewrite syntax, but reimplemented in PHP. It actually seems like more work, rebuilding the wheel. Of course, there are times when a PHP router is appropriate, like an MVC style where we're routing to controller actions rather than single PHP files.

For this, though, stick to mod_rewrite, which does the exact same thing. – Matchu Jul 27 at 14:14 This is especially useful, though, if you're creating software that is supposed to work regardless of the server system you use. Of course you still have to add the mod_rewrite rules mentioned above, but these are much easier to replicate on other servers (e.g. Lighttpd) than the full list of routes.

May be minor, but I find it useful. And, of course, you can create a more advanced system than this (mod_rewrite-like) one. – Franz Jul 27 at 19:07.

This is typically done with the mod_rewrite Apache extension. In the . Htaccess file, you would put something like: RewriteEngine On RewriteRule ^echo/(.+?)/(.+)$ echo.

Php? String=$1&font=$2 L The first line activates mod_rewrite. The second sets up a regular expression to route requests matching that pattern to the PHP file you want.

You will have to use the Rewrite engine which is the mod_rewrite in apache server.

To turn echo. Php into echo you'll need to use a rewriting facility for your web server. If you're running Apache, mod_rewrite is king.

For the rest of it, you just need to parse $_SERVER'REQUEST_URI' using a regex. You can use mod_rewrite to do this part also, but in case that's not an option, it can be done in straight PHP.

Problem is, "the rest" isn't quite that easy. You do have to use mod_rewrite or something similar on different servers than Apache to be able to use PHP to do the rewriting (well, except if you're talking about something along the lines of index. Php/article/id/123, which is regarded as ugly by many ;) – Franz Mar 22 '10 at 23:11 1 @Franz What I meant was, if mod_rewrite isn't an option, you can accept echo.

Php/bla+bla+bla/times and parse it using PHP only. Or you can use the hybrid solution: mod_rewrite to rewrite echo/anything to echo. Php/anything and then use the PHP-based URL parsing.

Or you can use mod_rewrite exclusively. – Dathan Mar 23 '10 at 3:00 Makes sense. Thanks for clarifying.

– Franz Mar 23 '10 at 9:00.

Have a look at the . Htaccess file that is generated in a new Zend Framework project. You can use it without the rest of the framework or use it as an example for your own URL-rewriting method.

An alternative to rewriting the URL through mod_rewrite, just set a php file to be the 404 error handler. That file can analyze the URL and determine how it should be processed. $path_parts = explode('/', $_SERVER'PATH_INFO'); echo $path_parts0.', '.

$path_parts1. ' font'; For performance reasons, you wouldn't want to configure apache to not send certain file types (i.e. Gif, jpg, png, etc) to PHP for handling.

While there are a number of different things you can do, as mentioned in the responses, you can't do it without adjusting configurations in the web server.

Don't forget to send the correct header (HTTP 200), though. As far as I remember, some servers automatically send the 404 header when using a 404 error handler unless you overwrite it. – Franz Mar 22 '10 at 20:01.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions