Removing /public from URLs

Added by John Porter almost 9 years ago

Hello everyone!

I've just successfully installed Redmine on my shared hosting account, and so far I'm very happy with it! What I would like to achieve is to remove the /public from the url. I have seen a technique in Retrospectiva where this can be done, but there site is down and I can't find it on Google.

I'm wondering if anyone here has done similar?

My current URL is http://redmine.designermonkey.co.uk/redmine/public and I would like all urls to be http://redmine.designermonkey.co.uk/

I have the current .htaccess at the root (a solution provided by my host)


RailsEnv "production" 
PassengerAppRoot      /var/www/vhosts/designermonkey.co.uk/subdomains/redmine/httpdocs/redmine/
RailsBaseUri /redmine/public

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteCond %{REQUEST_URI} ^/redmine/public/(.*)$
RewriteRule .* - [L]

RewriteRule ^$ redmine/public/ [L]
RewriteRule ^(.+)$ redmine/public/$1 [L]

This works when I manually type the URLs in, but all URLs created by Redmine are still using the /redmine/public path.

Anyone have any ideas how this can be done?

Replies (10)

RE: Removing /public from URLs - Added by Felix Schäfer almost 9 years ago

Remove the RailsBaseUri line and everything Rewrite-related.

RE: Removing /public from URLs - Added by John Porter almost 9 years ago

Felix,

Thanks for your reply! I've done as you suggested, and the site is still accessible from the root which is what I want.

Trouble is that all the links in Redmine are still generated with /redmine/public in them. How do I stop this behaviour and ,ake, for instance, the 'Projects' link into /projects not /redmine/public/projects ?

Cheers in advance...

RE: Removing /public from URLs - Added by Felix Schäfer almost 9 years ago

Have you restarted apache to make it aware of the changes?

RE: Removing /public from URLs - Added by John Porter almost 9 years ago

Ah. I have no control over that, it's a shared host...

Would closing the session and waiting for Passenger to clear the default PassengerPoolIdleTime of 300 be enough for that?

I don't think my host will restart the server for just little old me...

Cheers.

RE: Removing /public from URLs - Added by John Porter almost 9 years ago

Oh, hang on, the timeout has cleared, and the URLs are working now, however, there are no CSS or JS files being pulled through now.

I understand that I would have to remove the .htaccess from /public, which is done. How would I be able to get the stylesheets directory and javascripts directory to be recognised now?

Sorry for so many questions, I'm not a Rails person, but Redmine is the only software which does everything I want properly :)

Cheers in advance...

RE: Removing /public from URLs - Added by Felix Schäfer almost 9 years ago

John Porter wrote:

Oh, hang on, the timeout has cleared, and the URLs are working now, however, there are no CSS or JS files being pulled through now.

What is your DocumentRoot set to? And what <Directory> directives do you have defined?

RE: Removing /public from URLs - Added by John Porter almost 9 years ago

The DocumentRoot is set to my /httpdocs folder, where the application is at /httpdocs/redmine and public is /httpdocs/redmine/public

I have no way of altering this I'm afraid. I also can't find out the Directory directives either, as it's shared hosting. I know it would be better to move the DocumentRoot to /public, but alas, my hands are tied.

Can it be done with .htaccess rules?

RE: Removing /public from URLs - Added by Felix Schäfer almost 9 years ago

John Porter wrote:

The DocumentRoot is set to my /httpdocs folder, where the application is at /httpdocs/redmine and public is /httpdocs/redmine/public

I have no way of altering this I'm afraid. I also can't find out the Directory directives either, as it's shared hosting. I know it would be better to move the DocumentRoot to /public, but alas, my hands are tied.

Can it be done with .htaccess rules?

Not really. Can you put your redmine somewhere else and change make httpdocs a symlink to the redmine/public folder?

RE: Removing /public from URLs - Added by John Porter almost 9 years ago

I've done some jiggery pokery with sym-links and linked all the folders from /public into the root, as I can't move the docroot or the application.

Everything is working fine now, even though it's a hack...

Thanks very much for your help!

RE: Removing /public from URLs - Added by Felix Schäfer almost 9 years ago

John Porter wrote:

Everything is working fine now, even though it's a hack…

Well, not really a hack, but remember to check if there are any new files/directories in redmine/public not symlinked in httpdocs yet if you encounter some funny behavior.

Glad it works :-) Oh, and regarding restarting redmine: passenger will restart/reload a single rails app if you touch tmp/restart.txt in the app directory, that way you can restart the app without waiting for the timeout.

(1-10/10)