Child pages
  • Apache Mod_Rewrite Cheat Sheet
Skip to end of metadata
Go to start of metadata

Imported from:

Here is a new Apache Mod_Rewrite Cheat Sheet.

  • No labels


  1. Flags part (in attached PDF) was the interesting part for me, since I never
    was able to remember all of them.

    On Wed, Feb 8, 2012 at 7:53 PM, Dmitry A. <> wrote:
    > Here is a new Apache Mod_Rewrite Cheat Sheet.

  2. very useful, thanks !


  3. Hi guys,

    Also here is an example how to perform ModRewrite Auto-Redirects from Full
    Website to Mobile. I hope someone will find this useful since I spend quite
    some time getting to work :)

    RewriteCond %{HTTP_HOST} ^www\.jurmala\.com$ [NC]
    RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|js|css|ico) [NC]
    RewriteCond %{HTTP_REFERER} !^http://www\.jurmala\.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://m\.jurmala\.com/.*$ [NC]
    RewriteCond %{HTTP_USER_AGENT}
    RewriteCond %{HTTP_USER_AGENT}
    "android|blackberry|iphone|ipod|iemobile|mobile|palmos|webos|googlebot-mobi le"
    RewriteRule ^/?(.*){REQUEST_URI} [L,R=302,NE]


    *1.*"playbook-mobile|ipad|sch-i800|xoom|playbook|kindle|tablet|tablet-mobil e" -
    list of possible keywords in Tablet User Agent (they added as Exclusions so
    Auto-Redirect is not performed on then and they can see full website as
    normal Browsers). Example, iPad, Samsung Galaxy Tab, Sony PayBook and so on

    *2.* "android|blackberry|iphone|ipod|iemobile|mobile|palmos|webos|googlebot-mobi le"
    - list of possible keywords in Mobile / Smartphone User Agent.


  4. very nice example, I'll need some quiet reading to understand, but it's a good case of htaccess power.

    I don't remember if I've already shared this link, the best tool I've found for mobile detection:

    have fun :)

    Le vendredi 10 f

  5. Thanks Phil!

    Here is the Website were you can see my ModRewrite working -


  6. Btw, I use another method to detect mobile, which don't rely anymore on user agent (it can be spoofed, or inacurate/outdated): stating that all new platforms such as mobile and tablets are using browser that recognize CSS3, it's really easier to detect display size, and directly adapt the design to these dimensions.

    This is not exactly the same as performing a redirection, but I wanted to share this other method :)