roopurt18 Posted February 11, 2007 Share Posted February 11, 2007 Found this while doing some mod_rewrite, thought it could help others. http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.png Worthy of sticky?! Updated URL: http://www.addedbytes.com/mod_rewrite_cheat_sheet.png Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/ Share on other sites More sharing options...
wildteen88 Posted February 11, 2007 Share Posted February 11, 2007 I agree, I will sticky it. I always use the cheat sheets at ilovejackdaniels.com Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-181856 Share on other sites More sharing options...
keyurshah Posted May 26, 2008 Share Posted May 26, 2008 Hi, I am a small time php programmer. While searching for answers related to some of my queries, I found this link which, I thought will be helpful to my fellow programmers in this family. This web page has cheat sheets for: Actionscript, Ajax, Apache, ASCII Character Codes, CSS, Django, Firefox, Google, HTML/XHTML, JavaScript, MySQL, Perl, Photoshop/Gimp, PHP, Regular Expressions, Unix/Linux, Weblog, Windows, XML and more... The Cheat Sheet Round-Up: http://www.smashingmagazine.com/2006/10/30/cheat-sheet-round-up-ajax-css-latex-ruby/ Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-550097 Share on other sites More sharing options...
The Little Guy Posted January 8, 2009 Share Posted January 8, 2009 I found this site really nice with htaccess, I learned a lot: http://corz.org/serv/tricks/htaccess.php http://corz.org/serv/tricks/htaccess2.php <- The better page Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-732614 Share on other sites More sharing options...
saariko Posted March 5, 2009 Share Posted March 5, 2009 Found this while doing some mod_rewrite, thought it could help others. http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.png Worthy of sticky?! Please update the new URL to: http://www.addedbytes.com/mod_rewrite_cheat_sheet.png Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-777092 Share on other sites More sharing options...
dreamwest Posted June 12, 2009 Share Posted June 12, 2009 My favorite Crazy tricks: Here we are disabling the digital signature that would otherwise identify the server: # disable the server signature ServerSignature Off To increase performance on PHP enabled servers, add the following directive: # preserve bandwidth for PHP enabled servers <ifmodule mod_php4.c> php_value zlib.output_compression 16386 </ifmodule> # file caching- my favorite! ExpiresActive On ExpiresDefault A604800 # 1 week ExpiresByType image/x-icon A2419200 # 1 month ExpiresByType application/x-javascript A2419200 # 1 month ExpiresByType text/css A2419200 # 1 month ExpiresByType text/html A300 # 5 minutes # disable caching for scripts and other dynamic files <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"> ExpiresActive Off </FilesMatch> # disable directory browsing - no more index.php in every friggin directory Options All -Indexes This bit of voodoo will auto-correct simple spelling errors in the URL: # automatically corect simple speling erors <IfModule mod_speling.c> CheckSpelling On </IfModule> # instruct browser to download multimedia files AddType application/octet-stream .avi AddType application/octet-stream .mpg AddType application/octet-stream .wmv AddType application/octet-stream .mp3 Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-854333 Share on other sites More sharing options...
johnnyjohnny Posted July 14, 2009 Share Posted July 14, 2009 Is it possible to turn "control/test/hello?you=me" into "control/test?request=hello&you=me"? Tried using: RewriteRule ^control/(.+)/(.+)\?(.+)$ control/$1?request=$2&$3 Please help me. Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-875222 Share on other sites More sharing options...
Maq Posted July 14, 2009 Share Posted July 14, 2009 johnnyjohnny, this sticky is for posting your mod_rewrite cheat sheets, not questions. Please create your own thread rather than hijacking this one. Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-875225 Share on other sites More sharing options...
dreamwest Posted July 25, 2009 Share Posted July 25, 2009 htaccess rules Regex Character Definitions for htaccess2 [ ^ ] # the # instructs the server to ignore the line. used for including comments. each line of comments requires it’s own #. when including comments, it is good practice to use only letters, numbers, dashes, and underscores. this practice will help eliminate/avoid potential server parsing errors. [F] Forbidden: instructs the server to return a 403 Forbidden to the client. [L] Last rule: instructs the server to stop rewriting after the preceding directive is processed. [N] Next: instructs Apache to rerun the rewrite rule until all rewriting directives have been achieved. [G] Gone: instructs the server to deliver Gone (no longer exists) status message. [P] Proxy: instructs server to handle requests by mod_proxy [C] Chain: instructs server to chain the current rule with the previous rule. [R] Redirect: instructs Apache to issue a redirect, causing the browser to request the rewritten/modified URL. [NC] No Case: defines any associated argument as case-insensitive. i.e., "NC" = "No Case". [PT] Pass Through: instructs mod_rewrite to pass the rewritten URL back to Apache for further processing. [OR] Or: specifies a logical "or" that ties two expressions together such that either one proving true will cause the associated rule to be applied. [NE] No Escape: instructs the server to parse output without escaping characters. [NS] No Subrequest: instructs the server to skip the directive if internal sub-request. [QSA] Append Query String: directs server to add the query string to the end of the expression (URL). [s=x] Skip: instructs the server to skip the next "x" number of rules if a match is detected. [E=variable:value] Environmental Variable: instructs the server to set the environmental variable "variable" to "value". [T=MIME-type] Mime Type: declares the mime type of the target resource. [] specifies a character class, in which any character within the brackets will be a match. e.g., [xyz] will match either an x, y, or z. []+ character class in which any combination of items within the brackets will be a match. e.g., [xyz]+ will match any number of x’s, y’s, z’s, or any combination of these characters. [^] specifies not within a character class. e.g., [^xyz] will match any character that is neither x, y, nor z. [a-z] a dash (-) between two characters within a character class ([]) denotes the range of characters between them. e.g., [a-zA-Z] matches all lowercase and uppercase letters from a to z. a{n} specifies an exact number, n, of the preceding character. e.g., x{3} matches exactly three x’s. a{n,} specifies n or more of the preceding character. e.g., x{3,} matches three or more x’s. a{n,m} specifies a range of numbers, between n and m, of the preceding character. e.g., x{3,7} matches three, four, five, six, or seven x’s. () used to group characters together, thereby considering them as a single unit. e.g., (perishable)?press will match press, with or without the perishable prefix. ^ denotes the beginning of a regex (regex = regular expression) test string. i.e., begin argument with the proceeding character. $ denotes the end of a regex (regex = regular expression) test string. i.e., end argument with the previous character. ? declares as optional the preceding character. e.g., monzas? will match monza or monzas, while mon(za)? will match either mon or monza. i.e., x? matches zero or one of x. ! declares negation. e.g., “!string” matches everything except “string”. . a dot (or period) indicates any single arbitrary character. - instructs “not to” rewrite the URL, as in “...domain.com.* - [F]”. + matches one or more of the preceding character. e.g., G+ matches one or more G’s, while "+" will match one or more characters of any kind. * matches zero or more of the preceding character. e.g., use “.*” as a wildcard. | declares a logical “or” operator. for example, (x|y) matches x or y. \ escapes special characters ( ^ $ ! . * | ). e.g., use “\.” to indicate/escape a literal dot. \. indicates a literal dot (escaped). /* zero or more slashes. .* zero or more arbitrary characters. ^$ defines an empty string. ^.*$ the standard pattern for matching everything. [^/.] defines one character that is neither a slash nor a dot. [^/.]+ defines any number of characters which contains neither slash nor dot. http:// this is a literal statement — in this case, the literal character string, “http://”. ^domain.* defines a string that begins with the term “domain”, which then may be proceeded by any number of any characters. ^domain\.com$ defines the exact string “domain.com”. -d tests if string is an existing directory -f tests if string is an existing file -s tests if file in test string has a non-zero value Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-882498 Share on other sites More sharing options...
corbin Posted September 18, 2009 Share Posted September 18, 2009 Hrmmm.... Sorry. Ignore this . Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-920443 Share on other sites More sharing options...
Mahngiel Posted May 8, 2012 Share Posted May 8, 2012 --- Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-1344069 Share on other sites More sharing options...
QuickOldCar Posted December 1, 2014 Share Posted December 1, 2014 A tool for testing your htaccess rules online http://htaccess.madewithlove.be/ Quote Link to comment https://forums.phpfreaks.com/topic/37960-modrewrite-cheat-sheet/#findComment-1498146 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.