Friendly URLs - PHP [closed]

0

It is very important to know that friendly URLs are in order to make it easier for the user to 'memorize' the links in a certain way.

But, how can I change this?

  

www.midominio.com.mx/clientes.php?id=8

Because of this:

  

www.midominio.com.mx/clientes/pedrito

  • Could you explain in more detail how to do it?
  • Is it necessary to use .htaccess?
  • If necessary, how do I create a .htaccess on my localhost?
asked by Hoose 17.08.2016 в 08:05
source

2 answers

2

To create a .htaccess file you must create a new blank document and save the .htaccess file with the following extension

Now to create a Urls friendly would already depend on your project.

To start, an example of a friendly Urls.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([a-zA-Z0-9-/]+)$ detalle.php?id=$1

Explanation:

In an e-commerce website, every product has a description detailing the characteristics of the product.

Now in every detail of a product would be shown in this way: example.com/detalle.php?id=1

In the friendly Urls it would look like this: example.com/iphone-s6-plus

Back-end in PHP

The Back-End is the area that is dedicated to the logical part of a website, is responsible for everything to work as it should, the back-end is the back that is somehow not visible to the user since it is not about design, or graphic elements, it is about programming the functions that a site will have. The Back-End is the hard and pure programming, from the programming of the functions of the site to databases and even more.

The Back-end works all the time with programming languages, languages that require a logic since this area is also responsible for optimizing resources, the security of a site and so on. Things that the user does not see first but that there is code behind that is doing his work.

The programming languages used in the Back-end are currently PHP, Javascript, Phyton and Ruby. In addition to HTML and CSS, although basic, you should also know at least a little. Here I would like to talk about 2 things, first of all, I have mentioned 4 programming languages, but they are not all that exist and it is not obligatory to use each and every one of them, there are back-end programmers that only know some, not It is necessary to know all, it depends on what you want to program and the language capabilities. As a second thing I would like to comment is that although the Back-End must also know HTML and CSS, it is not necessary to know at a high level like a Front-End, it is simply to be able to create a basic structure in which to work .

The tools used in the Back-end are code editors, compilers, some debuggers to check errors and security, database managers and some other things.

The workflow of a back-end is to give functions to a site, usually the front-end makes a static site, and the back-end then gives functions and adapts the programmed system to that website . That is why people who are dedicated to the back-end also have to have at least basic front-end knowledge. To be able to put the 2 parts together in 1.

Source

    
answered by 17.08.2016 / 09:56
source
1

To create a htaccess is as simple as creating an empty file with the name .htaccess. The commands that you can create inside already depends on your needs, something very basic to make a friendly url could be:

# Activar RewriteEngine
RewriteEngine on

# Reescribir la URL solicitada por el usuario
#   Entrada:  clientes/NOMBRE/
#   Salida: clientes.php?id=NOMBRE
RewriteRule ^clientes/(\w+)/?$ clientes.php?id=$1

Before making sure you have the mod_rewrite module activated on your server, create a php file that contains this inside:

<?php phpinfo(); ?> 

When you open your php you will get a window with all the modules installed.

    
answered by 17.08.2016 в 09:34