# "public", how to remove it? + htaccess question. Help Please

**URL:** <https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507>\
**Category:** Deployment\
**Created:** [February 28, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507 "2008-02-28T21:20:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [February 28, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/1 "2008-02-28T21:20:57Z")

</div>

Hi, i’ve a little app which is working without problems, but i’ve a  
little annoyance. I’m using the cool rest methods, like users\_url, but  
when i do this the result is [www.domain.com/public/users](http://www.domain.com/public/users), how can i  
remove the “/public” string to get just [www.domain.com/users](http://www.domain.com/users) ?  
The other question is about htaccess, what do set in there? do you use  
just the one in the public folder or do you put one also in the root  
project folder? I’ve my project in the http\_public (i’m using a shared  
hosting for now), and now i’ve an htaccess which redirects every  
requests to the public folder, but in this way i can’t have any other  
directories in the root, but i’ve to put them in the rails public  
folder.

my htaccess is this:

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ /public/index.html [L]  
RewriteCond %{REQUEST\_URI} !^/public  
RewriteRule ^(._)$ /public/$1 [L]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(._)$ public/dispatch.fcgi/$1 [QSA,L]

thanks

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [February 28, 2008, 11:47pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/2 "2008-02-28T23:47:15Z")

</div>

On Thu, 2008-02-28 at 21:20 +0100, Xdmx X. wrote:

> folder.  
> You may want to set up your DocumentRoot to be the public/ directory.

Yours,

Tom

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [February 29, 2008, 2:50pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/3 "2008-02-29T14:50:36Z")

</div>

Tom C. wrote:

> On Thu, 2008-02-28 at 21:20 +0100, Xdmx X. wrote:
> 
> > folder.  
> > You may want to set up your DocumentRoot to be the public/ directory.
> 
> Yours,
> 
> Tom

Hi, i’ve tried to set DocumentRoot public/  
the temporally index.html page has been showed correctly, but when i try  
something which use rails like [domain.com/other/home](http://domain.com/other/home) doesn’t work: 500  
internal server error from apache.  
How have to set the .htaccess? one .htaccess in the root folder with  
just DocumentRoot public/ and another .htaccess in the public folder  
with the standard rails .htaccess, or just one .htaccess in the root  
with everything in there?  
Thanks

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [February 29, 2008, 4:49pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/4 "2008-02-29T16:49:50Z")

</div>

Xdmx X. escribiÃ³:

> > Tom
> 
> Hi, i’ve tried to set DocumentRoot public/  
> the temporally index.html page has been showed correctly, but when i try  
> something which use rails like [domain.com/other/home](http://domain.com/other/home) doesn’t work: 500  
> internal server error from apache.

Hi, what said [development|production].log?(when show error 500)

–  
Rafael Garcia Ortega

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 10, 2008, 4:09pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/5 "2008-03-10T16:09:23Z")

</div>

DocumentRoot directive must be in virtual host configuration file.  
Example:

\<VirtualHost \*:80\>  
ServerAdmin removed\_email\_address@domain.invalid  
ServerName [foo.com](http://foo.com)  
ServerAlias [www.foo.com](http://www.foo.com) [bar.com](http://bar.com) [www.bar.com](http://www.bar.com)  
DocumentRoot /absolute\_path\_to/public  
…

Regards

Xdmx X. escribiÃ³:

> DocumentRoot public/  
> RewriteRule ^(._)$ public/dispatch.fcgi [QSA,L]  
> DocumentRoot public/  
> RewriteRule ^(._)$ dispatch.fcgi [QSA,L]
> 
> ErrorDocument 500 “
> 
> ## Application error
> Rails application failed to  
> start properly”
> 
> #############

–  
Rafael Garcia Ortega

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 9, 2008, 7:02pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/6 "2008-03-09T19:02:55Z")

</div>

Rafael GarcÃ­a wrote:

> Hi, what said [development|production].log?(when show error 500)

Sorry for the late, i was trying something, anyway…  
this is the apache error (nothing in production.log):

#############

[Sun Mar 09 11:46:58 2008] [alert] [client 81.208.x.x]  
/home/dom1/public\_html/domain.com/.htaccess: DocumentRoot not allowed  
here

#############

this is caused by:

#############

DocumentRoot public/

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ public/index.html [QSA]  
RewriteRule ^([^.]+)$ public/$1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ public/dispatch.fcgi [QSA,L]

ErrorDocument 500 “

## Application error
Rails application failed to  
start properly”

#############

and:

#############

DocumentRoot public/

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ index.html [QSA]  
RewriteRule ^([^.]+)$ $1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 “

## Application error
Rails application failed to  
start properly”

#############

with this htaccess everything works fine, but it leaves the public  
referer in the url, and it hasn’t to be there:

#############

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ public/index.html [QSA]  
RewriteRule ^([^.]+)$ public/$1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ public/dispatch.fcgi [QSA,L]

ErrorDocument 500 “

## Application error
Rails application failed to  
start properly”

#############

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 10, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/7 "2008-03-10T17:31:40Z")

</div>

Xdmx X. escribiÃ³:

> Is it possible to do it using the .htaccess file? Because I don’t have  
> any access to the virtual host configuration, but only to the .htaccess  
> (and I can’t change hosting for now ☹ )

Another solution can be put a symlink from rails\_root/public to  
/home/dom1/public\_html/domain.com or specify rails\_root/public as domain  
directory.

Regards

–  
Rafael Garcia Ortega

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 10, 2008, 4:57pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/8 "2008-03-10T16:57:28Z")

</div>

Rafael GarcÃ­a wrote:

> DocumentRoot directive must be in virtual host configuration file.  
> Example:
> 
> \<VirtualHost \*:80\>  
> ServerAdmin removed\_email\_address@domain.invalid  
> ServerName [foo.com](http://foo.com)  
> ServerAlias [www.foo.com](http://www.foo.com) [bar.com](http://bar.com) [www.bar.com](http://www.bar.com)  
> DocumentRoot /absolute\_path\_to/public  
> …
> 
> Regards

Is it possible to do it using the .htaccess file? Because I don’t have  
any access to the virtual host configuration, but only to the .htaccess  
(and I can’t change hosting for now ☹ )

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 10, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/9 "2008-03-10T17:36:27Z")

</div>

Rafael GarcÃ­a wrote:

> Another solution can be put a symlink from rails\_root/public to  
> /home/dom1/public\_html/domain.com or specify rails\_root/public as domain  
> directory.
> 
> Regards

I’ll try with the last one, because i don’t know if i could have a ssh  
access.  
Thanks

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 13, 2008, 1:22pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/10 "2008-03-13T13:22:06Z")

</div>

Xdmx X. wrote:

> I’ll try with the last one, because i don’t know if i could have a ssh  
> access.  
> Thanks

Nothing… any way to do this using just the .htaccess file? i can use  
only that ☹

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 14, 2008, 3:46pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/11 "2008-03-14T15:46:11Z")

</div>

Are you confident your host has support for Rails?

Xdmx X. wrote:

> Xdmx X. wrote:
> 
> > I’ll try with the last one, because i don’t know if i could have a ssh  
> > access.  
> > Thanks
> 
> Nothing… any way to do this using just the .htaccess file? i can use  
> only that ☹

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 15, 2008, 1:24am UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/12 "2008-03-15T01:24:50Z")

</div>

Rick Martinez wrote:

> Are you confident your host has support for Rails?

Yes, in the panel there is rails (the hosting is bluehost)

---

<div class="post-metadata">

**Author:** ![xdmx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/53a042/32.png) [@xdmx](https://www.ruby-forum.com/u/xdmx)\
**Post date:** [March 15, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/public-how-to-remove-it-htaccess-question-help-please/130507/13 "2008-03-15T13:28:33Z")

</div>

Are you following their recipe?

[http://helpdesk.bluehost.com/kb/index.php?x=&mod\_id=2&id=232](http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=232)

–  
Anibal Rojas

> **[Home - Has Many Developers](https://hasmanydevelopers.com/)**
>
> We are the best choice for your building design and development

> **[RUBYCORNER.COM](https://www.rubycorner.com/)**
>
> RUBYCORNER.COM - Contact us for any business inquiries

[http://anibal](http://anibal),rojas.ve

On Mar 14, 8:24 pm, Xdmx X. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
