OK, I'm really confused as to how this might work/if it's possible or
even if I'm thinking about it right, so I'll just explain what I'd like
to do and you can shoot holes in it.
I have an app running that is for properties. Each property has it's own
"website" within my app and a user can tweak the content, it works well,
quite pleased so far.
So the URLs to a property look like this for the root
I didn't test if this will work but if it doesn't, it should be pretty
close. The idea is to have anything that goes to chalet-yeti.com go to
http://localhost:3000/properties/1 and anything that follows that url,
will be appended to the redirect.
Thanks for this, I'm getting *really* close I think.
That looks fine and I've tried - the redirects are taking effect but
it's not quite right.
The localhost:3000 part was just on my Mac, now I'm on the server I need
to replace that in some way with the root of the rails app - how do I
refer to it in a virtualhost tag.
Something like this I imagine (obviously not right)...
Thanks for this, I'm getting *really* close I think.
That looks fine and I've tried - the redirects are taking effect but
it's not quite right.
The localhost:3000 part was just on my Mac, now I'm on the server I need
to replace that in some way with the root of the rails app - how do I
refer to it in a virtualhost tag.
Something like this I imagine (obviously not right)...
<VirtualHost *:80>
ServerNamewww.apartment-marie.com
RewriteEngine on
RewriteRule ^(.*)$ APP_ROOT/properties/2/$1 [R]
</VirtualHost>
I tried simply
<VirtualHost *:80>
ServerNamewww.apartment-marie.com
RewriteEngine on
RewriteRule ^(.*)$ /properties/2/$1 [R]
</VirtualHost>
But that resulted in a mad loop of redirects !
as did...
<VirtualHost *:80>
ServerNamewww.apartment-marie.com
RewriteEngine on
RewriteRule ^(.*)$ apartment-marie.com/properties/2/$1 [R]
</VirtualHost>
Just to be clear (if it's not already), in the end I'm trying to get the
resulting url to look like this.http://www.apartment-marie.com/
andhttp://www.apartment-marie.com/full_details
with no mention of property in it.
Sounds like you only want to redirect someone touching the root of the
site, ie rewrite ^/$ not ^.*$.
If you want there to be no trace of the property id in the url then
you'll need to do something rails side, probably inspect the host name
in the rails and do something with that.
As Fred metioned. Looks like there's two rewrites here. Only needs to be
done from the Apache side and the other from rails (routes.rb)
I suggest you get the apache site going before attempting the other
rewrite.
That one didn't work - close but it gave me a double rendering of the
apartment-marie.com bit, something like this...
apartment-marie.com/apartment-marie.com/properties bla... so I edited
like so (here's the real file and it's live if it helps)..
This is much better (ignore the silly google api key message, will sort
in time)
guess this is the rails part. My routes file is here, not bothered if
the nested admin routes need to be acessesed with an ugly URL for now,
it's just the public facing pages that'd be important initially.
Anyone else comment as to if this combination of apache rewrites and
rails routing will play nicely together. I'll try it of course just
imagine that it may have been done before by somebody.
You could do it all with modrewrite. You'll just need to specify the
specific rules and rewrite actions for all your cases. It's not that
hard, just read up on it.
Thanks Luis, I'll refer to them and see if I can find a solution totally
via apache/modrewrite; I suspect I can! I need to get a handle on the
syntax of those rewrite commands, the command chain and regexes, should
be ok. I'll post back to this thread with the solution when I crack it.
You need to wear *many* hats in this game at times, not every problem
seems to be solvable in the RoR app itself (or perhaps it is but the
*pragmatic* approach for a quick win is to ssh to the server and get
funky with with apache config).