Welcome Guest, Not a member yet? Register   Sign In
mod_rewrite and .htaccess issue
#1

[eluser]phused[/eluser]
I have a CI app which offers its users a subdomain so they can access their account. The way it works is as follows:

Code:
user.mydomain.com => mydomain.com/user

If the user is trying to access a controller and method it would work as follows:

Code:
user.mydomain.com/session/login = > mydomain.com/user/session/login

(I'm using hook to override the way CI works with URLs)

I have managed to put together the following code but I'm having two issues with it and was wondering if anyone could point me towards the right direction.

Code:
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond $1 !^(index\.php|images|assets|favicon\.ico|robots\.txt|css)
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    # Custom Rules
    RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).localhost$
    RewriteRule ^(.*)$ http://localhost/%1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

    ErrorDocument 404 /index.php
    
</IfModule>

For some reason I get a ? after the subdomain on the URL. For example, if I accessed user.mydomain.com/session/login the URL that I see on my address bar is mydomain.com/user?/session/login - how can I get rid of the question mark?

Finally, I want to hide the redirects from the user. E.g. Whenever a user access his account (user.mydomain.com) I want the URL on the address bar to stay the way it is and not redirect to the actual path which is what my code actually does, I'd like the redirect to be internal if that makes sense? Is there any way I accomplish this?




Theme © iAndrew 2016 - Forum software by © MyBB