-
Notifications
You must be signed in to change notification settings - Fork 0
Developing bcms_mobile
peakpg edited this page Feb 9, 2012
·
1 revision
Here is a sample apache.conf file for testing bcms_mobile locally. The only thing that should need to be changed is the path to where the project root is, i.e.
/Users/username/projects/bcms_mobile/public
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/username/projects/bcms_mobile/public"
ServerName www.mobile.local
RailsEnv production
RewriteEngine On
# Set a 'full site' cookie if the user wants to stay on the full site. (2 weeks cookie by default)
RewriteCond %{QUERY_STRING} prefer_full_site=true
RewriteRule ^/?(.*)$ http://www.mobile.local/$1? [L,CO=prefer_full_site:true:.mobile.local:840]
# If the user wants the mobile site, set the cookie, redirect and stop.
RewriteCond %{QUERY_STRING} prefer_mobile_site=true
RewriteRule ^/?(.*)$ http://m.mobile.local/$1? [L,CO=prefer_full_site:false:.mobile.local:840]
# Redirect Mobile users to m. based on user agent
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteCond %{HTTP_COOKIE} !prefer_full_site=true
RewriteRule ^/(.*) http://m.mobile.local/ [L,R=302]
# Page Caching
RewriteRule ^/$ /cache/index.html [QSA]
RewriteRule ^([^.]+)$ /cache/$1.html [QSA]
# Cache Logging (Not strictly necessary)
RewriteLog /Users/username/projects/bcms_mobile/log/rewrite.log
RewriteLogLevel 9
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/username/projects/bcms_mobile/public"
ServerName m.mobile.local
RewriteEngine On
RewriteRule ^/$ /mobile_cache/index.html [QSA]
RewriteRule ^([^.]+)$ /mobile_cache/$1.html [QSA]
RailsEnv production
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/username/projects/bcms_mobile/public"
ServerName cms.mobile.local
RailsEnv production
</VirtualHost>