If you use only the symbol name, then something like the following:
RewriteRule ^ character /(.*)$/ character.php? Slug = $ 1
with a url like http://www.example.com/character/Jim_Carrey . Then you will need to find the name of the symbol in the database using the missing pass, since you will not have an identifier to look at it.
Alternatively, you can specify the identifier in the URL, if you need it, in relation to:
RewriteRule ^ character / ([0-9] +) /.*$/ character.php? Id = $ 1
So you can have a url like http://www.example.com/character/3/Jim_Carrey , which will include the name of the character (for SEO reasons, etc.), but also the identifier that you could find directly in their database.
Change a small PHP example for you:
<?php
Hope this helps! As always, use related parameters where possible for your needs, and do a good job of sanitizing your user data. The PEAR MDB2 module has a nice page on how to do this here .
Change 2 quickly and dirty :-)
.htaccess:
RewriteEngine On RewriteRule ^character/(.*)$ /character.php?slug=$1
Your .htaccess file will ideally be at the root of your site. For example / home / wayne / public_html / or wherever your index file is filed from
The URL that will match http://www.example.com/character/Jim_Carrey - with the phrase Jim_Carrey appearing in your $ _GET array as $ _GET ["slug"]. NB apologize, wrote that PHP is sleepy last night above, so it is not surprising that $ _POST will not work as its GET request :-) I updated it now!
Finally, you need to make sure your host supports the use of .htaccess files. Setting this up is not part of the SO scope, so any Apache configuration questions that you are best asked are https://serverfault.com/
richsage
source share