Welcome Guest, Not a member yet? Register   Sign In
htaccess and mobile site
#1

[eluser]Codepeak[/eluser]
Hi!

I'm about to develop a mobile version of my CodeIgniter application.

For this I've made a new controller called "mobile" that will handle the magic.

Visiting "http://domain/mobile/index/iphone" the correct page is shown. But since that URL isn't very nice, I want to spice it up abit.

In my .htaccess (before the rewrites that CI does) I've added:

Code:
RewriteCond %{HTTP_HOST} ^m.domain [NC]
RewriteCond $1 !^(mobile)
RewriteRule ^(.*)$ index.php?/mobile/$1 [R=301]

But that doesn't do the magic.

What I'm trying to achive is to have my visitors visit "http://m.domain/index/iphone". Right now that just gives me a 404. Any tips, tricks or obvious errors that I have made?

Tnx


Edit: http://m.domain and http://domain is pointing at the same directory on the server. The "m" site works exactly like the main site w/o any problems (except the rewrite problem above).
#2

[eluser]Codepeak[/eluser]
Solved.

Code:
RewriteCond %{HTTP_HOST} ^m\.domain\.dev
RewriteCond $1 !^(mobile|index\.php)
RewriteRule ^(.*)$ /index.php?/mobile/$1 [QSA,L]
#3

[eluser]drmanny[/eluser]
Hello, Can you share the controller called “mobile”, i am looking to do the same
Thanks
Manny
#4

[eluser]Codepeak[/eluser]
Hey!

The controller is extremly simple... Just a dir called "mobile" in the application/controller/ directory.

Example of some files:

application/controller/chat.php
Handles the chat

application/controller/iphone.php
Handles iPhone frontpage

application/controller/sys.php
Handles login/logouts.

Etc...

m.domain.com/iphone/index

is rerouted using the .htaccess above to

domain.com/mobile/iphone/index

Simple as that :-)




Theme © iAndrew 2016 - Forum software by © MyBB