Remove .php extension (explicitly written) for friendly URL [closed]

Code RewriteEngine On RewriteBase / # remove enter code here.php; use THE_REQUEST to prevent infinite loops RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP RewriteRule (.*)\.php$ $1 [R=301] # remove index RewriteRule (.*)/index$ $1/ [R=301] # remove slash if not directory RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /$ RewriteRule (.*)/ $1 [R=301] # add .php to access file, but … Read more

What are the safe characters for making URLs?

To quote section 2.3 of RFC 3986: Characters that are allowed in a URI, but do not have a reserved purpose, are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde. ALPHA DIGIT “-” / “.” / “_” / “~” Note that RFC 3986 lists fewer reserved punctuation marks … Read more

URL Friendly Username in PHP?

function Slug($string) { return strtolower(trim(preg_replace(‘~[^0-9a-z]+~i’, ‘-‘, html_entity_decode(preg_replace(‘~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i’, ‘$1’, htmlentities($string, ENT_QUOTES, ‘UTF-8’)), ENT_QUOTES, ‘UTF-8’)), ‘-‘)); } $user=”Alix Axel”; echo Slug($user); // alix-axel $user=”Álix Ãxel”; echo Slug($user); // alix-axel $user=”Álix—-_Ãxel!?!?”; echo Slug($user); // alix-axel

How to create friendly URL in php?

According to this article, you want a mod_rewrite (placed in an .htaccess file) rule that looks something like this: RewriteEngine on RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1 And this maps requests from /news.php?news_id=63 to /news/63.html Another possibility is doing it with forcetype, which forces anything down a particular path to use php to eval the content. So, in … Read more