php - htaccess mod_rewrite -
I'm trying to do something with it, whenever I go to a page:
http://www.example.com/character.php?id=3
I want to overwrite it:
http://www.example.com/character/Jim_Carrey
Which is the line of the curriculum, id character .. .
For such an example ... I have tried to work with it, but I could not get much of the HTACK production Yes, because I .htaccess
is the truth.
This is actually another way:
-
On the website, you write to all your links the way you want to see it. For example
http://www.site.com/character/Jim_Carrey
-
In your database, you add fields, usually "slug" Or "post_slog" which indicates "part of UML" Gimarera. This is a primary element, which will be very much in the way of the primary key. So make sure that you have a function that takes care of creating a slug based on a given string string (for example the title of the post) and make sure there is no duplicate.
-
Then you do something like this in your .htaccess (on the root folder)
Reviving On Rewriteable ^ Characters / ([a-z0 - 9 _ \ -] +) / $ character.php? Slug = $ 1 [L, NC]
-
In the end, in your character.php script, you do not encrypt the database against the id but the post_slug field against.
Comments
Post a Comment