Using .htaccess to add trailing slashes to all URIs or URLs | Geekology Apache's Rewrite Module allows developers to define extensive URL Rewriting and Redirecting Conditions & Rules, one of which could be to add trailing slashes to Representational State Transfer (RESTful) URLs. RESTful URLs are Uniform Resource Indicators (URIs) that are more user- and SEO-friendly than standard GET-based URIs. For example (GET vs. ...or (GET vs. To use URL Rewriting to add a trailing slash to all RESTful URIs, create a .htaccess file in your website's root folder (if it doesn't exist yet), open it, and add this content: <ifModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} ! The RewriteEngine, RewriteBase, RewriteCond, and RewriteRule lines tell Apache to enable the Rewrite Module, set the base directory to the website's root directory, and redirect all requests for non-existant files or directories to the website root directory.
rewrite Available Languages: en | fr Summary This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps. This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) and can generate query-string parts on result. Further details, discussion, and examples, are provided in the detailed mod_rewrite documentation. Quoting Special Characters Environment Variables This module keeps track of two additional (non-standard) CGI/SSI environment variables named SCRIPT_URL and SCRIPT_URI. Example Rewriting in Virtual Hosts RewriteEngine On RewriteOptions Inherit
URL Rewriting | redirecting URLs with Apache’s mod_rewrite Path // → → URL REWRITING The Apache server’s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user’s knowledge. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the ‘dirty’ URLs coming from a poor publishing system — giving you URLs that are friendlier to both readers and search engines. This page was last updated on 2012-08-21 An Introduction to Rewriting Readable URLs are nice. However, there are some cases when the best possible information design can’t stop your site’s URLs from being nigh-on impossible to use. This is a horrible URL, but it and its brethren are becoming increasingly prevalent in these days of dynamically-generated pages. It exposes the underlying technology of the website (in this case ASP). Luckily, using rewriting, we can clean up this URL to something far more manageable.
A T-SQL Regular Expression Library for SQL Server 2005. Free source code and programming help Introduction With the advent of CLR integration into SQL Server 2005, it has become incredibly easy to extend the power of the T-SQL programming language. Two of the areas that can be improved upon by way of CLR integration are string matching and string manipulation. Background T-SQL has a handful of basic string matching functions (e.g. SQL Server 2005 now allows you to create user defined functions (among other things) using your .NET language of choice. Using the Code General Approach My objective here is to wrap some of the more commonly used static methods of the RegEx class in the .NET Framework into something useable in a T-SQL environment. Interface All four of the functions listed in this article share the same first two parameters: @Input NVARCHAR(MAX) This is the string to be analyzed. @Pattern NVARCHAR(MAX) This is the regular expression which will be executed against the @Input parameter. In addition, all four functions share the same last parameter. @IgnoreCase BIT Functions Name
Crazy Advanced Mod_Rewrite Tutorial Are you an advanced mod_rewrite expert or guru? This article is for YOU too! Just make sure to read all the way to the bottom.. The following undocumented techniques and methods will allow you to utilize mod_rewrite at an "expert level" by showing you how to unlock its secrets. Most if not all web developers and server administrators struggle with Apache mod_rewrite. Why mod_rewrite is so tough ^ I have come to the conclusion, after many hours of zenful thought, that the reason mod_rewrite is so tough is pretty obvious, people are trying to apply regular-expressions to URLs and Variables that they don't really understand. Hit-Or-Miss with mod_rewrite ^ A lot of the mod_rewrite "experts" and "gurus" floating around the net absolutely know their mod_rewrite, but what separates them from a beginner or novice is for the most part an understanding of what the URLS and Variables look like that are targeted by the regular expressions. Pretty simple right? Why? When Not To Use Mod_Rewrite ^ <? YES!
Apache mod_rewrite mod_rewrite provides a way to modify incoming URL requests, dynamically, based on regular expression rules. This allows you to map arbitrary URLs onto your internal URL structure in any way you like. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. Rewrite rules can operate on the full URLs, including the path-info and query string portions, and may be used in per-server context (httpd.conf), per-virtualhost context (<VirtualHost> blocks), or per-directory context (.htaccess files and <Directory> blocks). Since mod_rewrite is so powerful, it can indeed be rather complex. mod_rewrite: A Beginner's Guide to URL Rewriting This article was written in 2002 and remains one of our most popular posts. If you’re keen to learn more about URLs, you may find this recent article on the “www” prefix, by Craig Buckler, of great interest. So you’re a web developer who has all the bells and whistles on your site, creates Web-based applications that are both beautiful and work well. But what about these issues? Applications Must Be Safe A user must not be able to harm your site in any way by modifying a URL that points to your applications. For example, imagine we have a simple script that shows all the products in a category. Generally, it’s called like this: myapp.php? But what will this application do if ScriptKiddie(tm) comes and types this in his browser: myapp.php? Well, many of the sites I’ve seen will drop some error message complaining about use of the wrong SQL query, invalid MySQL resource ID, and so on. Applications Must Be Search-Engine Friendly myapp.php? myapp.php “you have an error in your sql syntax” .php -forum
Rejex lets you craft regular expressions on-the-fly Rejex is a very handy little site for building and testing regular expressions on the fly. It's composed of four simple text boxes and a very informative cheat sheet (not shown above, but after the jump). You feed your text into the "Test String" box (the middle one), and then your expression into the top box, and immediately see the matches in the bottom box. Here I am searching for instances of the letter "o" which are either at the beginning or the end of a word, so I got a match for "over" but not for "fox". Half the tool's value lies with the informative cheat sheet, showing you exactly what each regex character does. The regex cheat sheet:
Unicode Transformation Formats The ISO 10646 Universal Character Set (UCS, Unicode) is a coded character set with more than 40'000 defined elements. It is expected that this cardinality will grow to more than 100'000 soon, through additional definitions for characters that do not yet have a coding, so that all the world's characters will be represented in Unicode. But how can you represent more than 2^8 = 256 characters with 8bit bytes? This chapter explains and discusses the concepts of coded character sets versus their encoding schemes as well as the various Unicode representation schemes along with their implementation level on Unix: most prominently UTF-8 beside its precursors EUC and UTF-1 and its alternatives UCS-4, UTF-16, UTF-7,5, UTF-7, SCSU, HTML, and JAVA. Another fine web page describing these subjects is Jukka Korpela's tutorial on character code issues. What is a coded character set? An abstract character is a unit of textual information like the U+0041 LATIN CAPITAL LETTER A ('A'). The naïve approach
301 Redirect Htaccess Examples You are here: home 301 redirects When updating any website with a new page structure, re-naming page URL's or changing the path of web pages by adding folders or altering folder names, many webmasters forget or simply don’t appreciate the SEO benefits of using Mod Rewrite or simple "301 redirects" to redirect old pages to new. A different, but equally popular application for 301 redirects is to redirect all visitors to a certain website to another domain, either on a page by page basis or to redirect all pages on an old unused domain to a single page on a new domain - the homepage for example. 301's are often referred to as "Redirect Permanent", so as the name implies they are used to permanently redirect one web page to another - and are recommended by Google as the best method of implementing web page redirects. HTACCESS File SEO Benefits of 301 Redirects Usability Benefits Mod Rewrite Procedure & 301 Redirect Examples Mod Rewrite rules are applied using an HTACCESS file. Wildcard Redirects