How to create user-friendly and seo-friendly urls in jsf?

If this is intended as an improvement of an existing application, then you basically need a Filter which detects “dirty” and “friendly” URLs. When it detects a “dirty” URL, then it should redirect the request to a “friendly” URL by HttpServletResponse#sendRedirect(). When it detects a “friendly” URL, then it should forward the request to the … Read more

Should I use accented characters in URLs?

There’s no ambiguity here: RFC3986 says no, that is, URIs cannot contain unicode characters, only ASCII. An entirely different matter is how browsers represent encoded characters when displaying a URI, for example some browsers will display a space in a URL instead of ‘%20’. This is how IDN works too: punycoded strings are encoded and … Read more

How can I create a friendly URL in ASP.NET MVC?

There are two steps to solve this problem. First, create a new route or change the default route to accept an additional parameter: routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}/{ignoreThisBit}”, new { controller = “Home”, action = “Index”, id = “”, ignoreThisBit = “”} // Parameter defaults ) Now you can type whatever you want to … Read more

Generate SEO friendly URLs (slugs) [closed]

I like the php-slugs code at google code solution. But if you want a simpler one that works with UTF-8: function format_uri( $string, $separator=”-” ) { $accents_regex = ‘~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i’; $special_cases = array( ‘&’ => ‘and’, “‘” => ”); $string = mb_strtolower( trim( $string ), ‘UTF-8’ ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string … Read more

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