Apache Mod_Rewrite Cheat Sheet

4 views
Skip to first unread message

Dmitry A.

unread,
Feb 8, 2012, 12:53:43 PM2/8/12
to in-portal...@googlegroups.com
Here is a new Apache Mod_Rewrite Cheat Sheet.


mod_rewrite-cheat-sheet-v1.pdf

Alexander Obuhovich

unread,
Feb 8, 2012, 2:00:50 PM2/8/12
to in-portal...@googlegroups.com
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. <dand...@gmail.com> wrote:
Here is a new Apache Mod_Rewrite Cheat Sheet.





Phil

unread,
Feb 8, 2012, 3:39:23 PM2/8/12
to in-portal...@googlegroups.com
very useful, thanks !


Envoyé avec Sparrow

Dmitry A.

unread,
Feb 10, 2012, 4:17:01 PM2/10/12
to in-portal...@googlegroups.com
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} !"playbook-mobile|ipad|sch-i800|xoom|playbook|kindle|tablet|tablet-mobile" [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^/?(.*) http://m.jurmala.com%{REQUEST_URI} [L,R=302,NE]

NOTES:

1. "playbook-mobile|ipad|sch-i800|xoom|playbook|kindle|tablet|tablet-mobile" - 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-mobile" - list of possible keywords in Mobile / Smartphone User Agent.



DA

Phil

unread,
Feb 10, 2012, 5:15:09 PM2/10/12
to in-portal...@googlegroups.com
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 :)

Dmitry A.

unread,
Feb 10, 2012, 5:18:02 PM2/10/12
to in-portal...@googlegroups.com
Thanks Phil!

Here is the Website were you can see my ModRewrite working - http://www.vic.gov.au


DA

Phil

unread,
Feb 10, 2012, 5:44:09 PM2/10/12
to in-portal...@googlegroups.com
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 :)


Envoyé avec Sparrow

Reply all
Reply to author
Forward
0 new messages