Forum Moderators: phranque

Message Too Old, No Replies

Subdomain Pain!

need to rewrite subdomain to a folder

         

allagents

2:50 pm on Oct 7, 2011 (gmt 0)

10+ Year Member



The boss has changed his mind! :-o
our site, lets say example.com, which runs from the root /

also has a subdomain, sub.example.com
the subdomain actually resides in /portal/public

but now ive been asked to rewrite all requests!
he doesn't want anyone typing sub.example.com/whatever/whatever-else

now he wants

example.com/sub/whatever/whatever-else

i know it can be done, but my htaccess and regex skills are lame
(too much time spent mucking around with other stuff)

anyone have a clue?
cheers
delboy

lucy24

6:25 pm on Oct 7, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh, maybe, maybe

:: twiddling thumbs ::

but first you gotta show us the results of your lame efforts so people can tear them to pieces. (That is not the exact wording of the Forums Charter, but you get the idea.)

The Charter does not say anything about bosses changing their minds. That is what the Foo forum is for. If there isn't a "Today's Rant" thread, maybe there should be ;)

allagents

12:36 pm on Oct 10, 2011 (gmt 0)

10+ Year Member



ok, well my htaccess for / is like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|(.*)\.swf|uploadify|application|system|assets|js|robots\.txt)
RewriteRule ^([^/]+)/$ index.php?id1=$1 [NE,L]
RewriteRule ^([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2 [NE,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2&id3=$3 [NE,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2&id3=$3&id4=$4 [NE,L]
AuthName "Root"
AuthUserFile "/var/.htpasswd"
RewriteRule info/$ info.php [L]


#this is for a trailing slash#
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

the normal php site at / uses urls like domain.com/$id1/$id2/$id3/$id4
for nice looking url params (which probably wont help)


the htaccess in /portal/public is as follows:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

which basically pushes every request through zends index.php

is it possible to check where you are coming FROM?

lucy24

2:42 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



is it possible to check where you are coming FROM?

You mean, where the user is? You can look at their IP address and the referer, but sadly there is no way to find out what site they are on if they do a type-in or bookmark. ("Fingers that touch Facebook shall never touch mine," that kind of thing.)

allagents

2:57 pm on Oct 10, 2011 (gmt 0)

10+ Year Member



what i mean is that the portal.site.com has links that go to /, when in actuality without the subdomain this would be /portal/public, so can we tell if the request came from that part of the site so we can redirect?

g1smd

2:58 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can test HTTP_HOST to see which hostname they requested.