0

In my document root, I have deployed two Laravel applications to two different subfolders. (i.e. http://example.com/dev and http://example.com/test). Here dev and test are the subfolders.

I want http://example.com/demo/task/132 to be directed to http://example.com/demo/public/task/132.

\[document root]
-- \dev
   -- [laravel home]
-- \test
   -- [laravel home]

Is there a way to handle public folder in the paths using .htaccess? Basically I want to get rid of public from the URL.

Lakmal Premaratne
  • 1,159
  • 7
  • 18
  • 34

1 Answers1

0

Can you try this :

dev/public/.htacess

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /dev/
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

test/public/.htacess

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /test/
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Mihir Bhende
  • 8,677
  • 1
  • 30
  • 37
  • Did you mean to put it inside `dev/.htaccess` instead of `dev/public/.htaccess` ? – Lakmal Premaratne May 07 '17 at 09:55
  • It doesn't work no matter if I put it either to `dev/.htaccess` or `dev/public/.htaccess`. I get an error raised from RouteCollection.php – Lakmal Premaratne May 07 '17 at 10:00
  • Is your mod_rewrite module enabled in php? – Mihir Bhende May 07 '17 at 10:00
  • Also in your virtualhost check is allowoverride is set to All instead of None – Mihir Bhende May 07 '17 at 10:06
  • This is a shared hosting environment and I was able to run the application when I had installed it to root folder. Then my .htaccess was pointing to public folder and it was working perfectly. That is, I was able to go to example.com/task/312. Therefore, I think mod_rewrite should have been enabled. – Lakmal Premaratne May 07 '17 at 10:13
  • Check this out if it helps : http://stackoverflow.com/questions/23837933/how-can-i-remove-public-index-php-in-the-url-generated-laravel – Mihir Bhende May 07 '17 at 10:20