php User friendly URLs instead of Query Strings?
This functionality cannot be implemented using only PHP. You need to configure URL rewriting for your HTTP server, which will transform the user-friendly URLs into query strings which your scripts can understand. In the case of Apache, you should look into mod_rewrite, which can usually be configured through .htaccess files.
php User friendly URLs instead of Query Strings?
Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).
This is accomplished through the use of .htaccess to modify how the URL is sent to the client. Or as other people say, to prettify the URL. Here are some links to articles to help you get started with the mod_rewrite rules required to make this function.
php User friendly URLs instead of Query Strings?
RewriteEngine on RewriteRule ^cat_([0-9]*) /?cat=$1 [N,QSA] RewriteRule ^item_([0-9]*) /?item=$1 [N,QSA]
Here's a specific .htaccess example that will do what you're looking for:
Just put the above in a file called .htaccess in your root web folder, and you'll be good to go.
Note that you may have to enable mod-rewrite in your apache server if it's not already enabled (most shared hosting providers have it enabled)
You want to use .htaccess to rewrite your URLs internally and route them appropriately to your application.
php User friendly URLs instead of Query Strings?
php User friendly URLs instead of Query Strings?
This functionality cannot be implemented using only PHP. You need to configure URL rewriting for your HTTP server, which will transform the user-friendly URLs into query strings which your scripts can understand. In the case of Apache, you should look into mod_rewrite, which can usually be configured through .htaccess files.
php User friendly URLs instead of Query Strings?
This functionality cannot be implemented using only PHP. You need to configure URL rewriting for your HTTP server, which will transform the user-friendly URLs into query strings which your scripts can understand. In the case of Apache, you should look into mod_rewrite, which can usually be configured through .htaccess files.
php User friendly URLs instead of Query Strings?
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 [L] </IfModule>
example.com/class/function/ID
mod_rewrite
.htaccess with Codeigniter:
You will need to activate the mod_rewrite and create the file .htaccess
php User friendly URLs instead of Query Strings?
RewriteEngine on RewriteRule ^cat_([0-9]*) /?cat=$1 [N,QSA] RewriteRule ^item_([0-9]*) /?item=$1 [N,QSA]
Here's a specific .htaccess example that will do what you're looking for:
Just put the above in a file called .htaccess in your root web folder, and you'll be good to go.
Note that you may have to enable mod-rewrite in your apache server if it's not already enabled (most shared hosting providers have it enabled)
You want to use .htaccess to rewrite your URLs internally and route them appropriately to your application.
php User friendly URLs instead of Query Strings?
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 [L] </IfModule>
example.com/class/function/ID
mod_rewrite
.htaccess with Codeigniter:
You will need to activate the mod_rewrite and create the file .htaccess
Discussion