Remove public/ when running in subdirectory

Hello,
I’m running my invoice ninja installation in a subdirectory (http://website.com/crm) and for now I have to add an “/public” to the URL but how do I configure it to use it without that. I already uncommented that line in .htaccess but it always says “Sorry, the page you are looking for could not be found.”. How to fix this?

Thanks for your help.

1 Like

You need to map your web server root to the /public folder.

I can’t. I’m running on a shared hosting and want to access it under the URL http://website.com/crm .

I noticed this in the comments which probably explains why the .htaccess change isn’t working.

“I had the same problem as tridnguyen. This method only works if the base laravel folder is the webroot, it wont work if the base laravel folder is a subfolder of the webroot”

https://coderwall.com/p/erbaig/laravel-s-htaccess-to-remove-public-from-url

Maybe this will work: http://stackoverflow.com/a/28735930/497368

Per the comment, I’d suggest checking your .env isn’t accessible.

Thanks for looking up this. Unfortunately it doesn’t work smoothly (bootstrap failure).
I decided to go with a subdomain (created with cPanel subdomain editor; path to /user/public_html/crm/public) then but there comes the next error. I updated the .htaccess in public/ but it seems like invoice ninja doesn’t read my input.

If you’re using a subdomain you may need to un-comment this line:

https://github.com/invoiceninja/invoiceninja/blob/master/public/.htaccess#L22

Yeah, I already did so but still, the above described error occurs.

What’s the exact error you’re seeing?

Ahh, it’s working now. Seemed to be an issue with Firefox. I cleared the cache, etc. Now it’s working. :slight_smile:

Great to hear!

Thanks for your awesome support.

The topic’s four years old but i still did not find a solution to install ninja in a subdirectory elsewhere. What worked for me is the following workaround:
https://mydomain.com/invoice
is now the URL of the loginpage (e.g.). The Ninjainstallation is in the directory “invoice” inside the documentRoot. The mentioned line from other comments in the .htaccess inside “docRoot/invoice/” now reads
RewriteRule ^(.)$ /invoice/public/login [L]*

Now to get it a smarter look i renamed the folder “public” to “system” and renamed it in the .htaccess, .env and server.php as well as in the system settings!. The adressline still looks like “mydomain.com/invoice/system/” etc. while logged in but provides a more comfortable login.
Still not being tested for longer this solution could cause issues, so please report problems.
Hope this helps you out there wanting to run Ninja in a subdirectory.

i would love to use www .mydomain/pay but it hard…using apache…i keep getting an error

Sorry to read, the above solution worked for my Ninja4 installation. I did not try that with Ninja5.
And to be honest, i once installed the ninja inside docRoot and moved it afterwards one directory downwards.

1 Like

if yours work well…thats good. I will try your solution. would be nice it was made to run easily in a a folder…easy to keep ninja a little hidden then using a direct domain / straight access www. mydomain .com/getoff …i can always rename folder to hide my small coins!

kindly give an example and where exactly to make such changes please, thanks