I recently created a mobile version for my website and redirect to a mobile version.
The mobile version is in a subdomain (folder) in my root. Redirecting is done through a php script in the header of all files in the root, so far the index.php
is working.
Now I need to add rules into my htaccess
so all urls as in the normal root will also work / maintain same structure in the subdomain folder.
www.mysite.com
and for mobile it is m.mysite.com
url structure in site:
For desktop following urls and files out of root
www.mysite.com/basisscholen/
www.mysite.com/middelbaar-onderwijs/
www.mysite.com/hbo-universiteit/
www.mysite.com/basisscholen/plaats/m/
www.mysite.com/middelbaar-onderwijs/plaats/m/
www.mysite.com/hbo-universiteit/plaats/m/
www.mysite.com/basisscholen/plaats/m/miami/
www.mysite.com/basisscholen/plaats/m/miami/myschool/
For desktop following urls and files out of folder (m) so that different css can be used:
m.mysite.com/basisscholen/
m.mysite.com/middelbaar-onderwijs/
m.mysite.com/hbo-universiteit/
m.mysite.com/basisscholen/plaats/m/
m.mysite.com/middelbaar-onderwijs/plaats/m/
m.mysite.com/hbo-universiteit/plaats/m/
m.mysite.com/basisscholen/plaats/m/miami/
m.mysite.com/basisscholen/plaats/m/miami/myschool/
Here are my htacces rules for the normal desktop version:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
RewriteRule ^ xx-xxxx%{REQUEST_URI} [L,NC,R=302]
RewriteRule ^\.html$ /index.php
RewriteRule ^basisscholen/$ basisscholen.php?id=basisscholen [L]
RewriteRule ^middelbaar-onderwijs/$ middelbaar-onderwijs.php?id=middelbaar-onderwijs [L]
RewriteRule ^hbo-universiteit/$ hbo-universiteit.php?id=middelbaar-onderwijs [L]
RewriteRule ^basisscholen/plaats/([A-Za-z0-9-]+)/?$ basisscholen.php?letter=$1 [L,B]
RewriteRule ^middelbaar-onderwijs/plaats/([A-Za-z0-9-]+)/?$ middelbaar-onderwijs.php?letter=$1 [L,B]
RewriteRule ^hbo-universiteit/plaats/([A-Za-z0-9-]+)/?$ hbo-universiteit.php?letter=$1 [L,B]
RewriteRule ^([^/]+)/plaats/([^/]+)/([^/]+)/?$ plaats.php?type=$1&letter=$2&link=$3 [L,B]
RewriteRule ^([^/]+)/plaats/([^/]+)/([^/]+)/([^/]+)/?$ school.php?type=$1&letter=$2&plaatsnaam=$3&schoolnaam=$4 [L,B]
What I need is how the htacces rules should be to get subdomain url structure working exactly as main site. had a lot of white screens, acces forbidden or all url rewritten to subdomain.
Also tried a lot of suggestions out of other topics, can somebody please help me ?
Cor