browser lang:en
i want talk about someting which i use frequently for all of my mod_rewrite urls. I have my web site and i want the title on my url but i noticed that some titles had weird special characters you find on your keyboard for example some of them are these
! @ # $ % ^ & * ( ) _ + { } | : " < > ? [ ] \ ; ' , . / / * - + ~ ` - = space
so lets say for example i have a page title called:
I am this @ thisdomain.com! [contact] & phone # (213) 555-1212
as you can see from my example title, i would have to make the url look like this:
I am this @ thisdomain.com! [contact] & phone # (213) 555-1212.html
That just wouldn't work, how about if i could make it look like this:
i-am-this-thisdomain-com-contact-phone-213-555-1212.html
So how can you do this. Well, if you have PHP you can very easy. So I created a function to make this possible and this is the script code:
Code:
# This function makes any text into a url frienly
function clean_url($text)
{
$text=strtolower($text);
$code_entities_match = array(' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
$code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
$text = str_replace($code_entities_match, $code_entities_replace, $text);
return $text;
}
This function will make your url look shorter and it will be search engine friendly. it will remove all those unwantd spcial characters you find on your keyboard above the number 1234567890 and some others, this way you links witll look better and liking to them will be easier by removing all the unwanted special strings with a simple php function snippet wiget in your html web pages.
After this you can receive your url in the landing page with the following script:
For example if you have a mod_rewrited url as /news/24-welcome-to-my-site.html
$page = $_GET[id];
$divider = explode("-", $page);
$id = $divider[0];// get the first thing before - (in this case an ID number)
$query = mysql_query("Select * from news where id='$id'");
PHP is one of the most widely used open-source server-side scripting languages that exist today. With over…
in:Scripts and tutorials (0 comments)In a FBML Facebook App, your quick jump menu will require a little tweak to work in FBJS…
in:Scripts and tutorials (0 comments)Every single day, someone, somewhere is discussing something important to your business; your brand, your executives, your…
in:Scripts and tutorials (0 comments)The Singleton Pattern is one of the GoF (Gang of Four) Patterns. This particular pattern provides a…
in:Scripts and tutorials (0 comments)Because of the near-spherical shape of the Earth, calculating an accurate distance between two points requires the use…
in:Scripts and tutorials (1 comments)With this script we can limit the download speed // local file that should be send to the client $local_file…
in:Scripts and tutorials (0 comments)Some hosts disabled the ini setting allow_url_fopen. This also means that the ability to easily grab images…
in:Scripts and tutorials (0 comments)The act to verify if a file exists, is one of more important tasks related to files operations,…
in:Scripts and tutorials (0 comments)
