tags:

views:

64

answers:

3

hi guys I've build a website using the zend framework and using clean urls - however I need to set up a subdomain such that it points to only one folder on my website i.e I want the subdomain admin.mysite.com to point to mysite.com/admin and I wanna do it using my htaccess file

EDIT -------

This is my htaccess file:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
RewriteRule !\.(js|ico|gif|jpg|png|css|htm|html)$ index.php 

RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]


AddType text/css .css
AddHandler php5-script .php
A: 

On admin.mysite.com "/" you can symlink to "/admin"

fernyb
A: 

Try something like this above your existing URL rerwites:

RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]

Edit: To prevent it from being interpreted as a Zend Frameowrk controlleradd the following above your existing RewriteConds to prevent it from transforming your admin URLs:

RewriteCond %{REQUEST_URI} !^/admin

And I think that should take care of everything.

Edit: Your .htaccess file should look more like the following, though I don't think any of the changes would relate to your 403 error, but maybe we'll get lucky. If not, I'll keep thinking of what might cause that.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]

# Don't rewrite requests on admin subdomain to the Zend Framework handler
RewriteCond %{HTTP_HOST} !^admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

RewriteCond %{HTTP_HOST} !^admin
RewriteRule !\.(js|ico|gif|jpg|png|css|htm|html)$ index.php [L]

RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]

AddType text/css .css
AddHandler php5-script .php
Tim Stone
I don't want the admin folder to be treated as a controller - actually my admin panel is a different application so I wish it to run independantly. My old host had a real simple panel to create subdomains but on my new host I have to write up in an htaccess file :(
Ali
Ah, gotcha. I've updated the answer now, you can try that and see if it works.
Tim Stone
I got a 403 error for some weird reason? my admin folder is in my public_html folder...
Ali
help please :'(
Ali
Hmm, if you go to `http://mysite.com/admin` directly, do you get the 403 error?
Tim Stone
hmmmm nope then I get the no controller defined error...
Ali
And your `.htaccess` file is in your `public_html` folder, right?
Tim Stone
yes exactly.. its working fine for everything else.. lemme show the htaccess file
Ali
CHeck my updated post...
Ali
I've updated my answer now, see if that solves anything (it does fix a few potential problems, but I'm not confident it fixes the problem you're having right now)
Tim Stone
hmmmmm ok I'm getting this error now:ForbiddenYou don't have permission to access / on this server.
Ali
Very weird. Do you have access to the server logs? Maybe they'll provide a little more insight on exactly what's being requested so we can figure out why it's giving you that 403 error.
Tim Stone
Sorry for the late update - ok now my subdomain is working BUT its not pointing to the admin folder for some weird reason? instead its pointing to the website root :( and looks a mess
Ali
I made an update just to be safe, but I don't think it's related. I'll keep thinking of what the issue might be and hopefully I'll come up with something. I know this works on my test server, so there must be something I'm overlooking.
Tim Stone
A: 

Hi, on subdomain admin.mysite.com use directive Redirect.

Redirect permanent / http://mysite.com/admin

Or you can use proxy:

ProxyPass / http://mysite.com/admin
ProxyPassReverse / http://mysite.com/admin
ProxyPreserveHost on
pejuko