0

I am using laravel 5 with default directory structure. For removing public folder from url I am using following code in .htaccess

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

I am using xampp and my path is like this http://localhost/pro/laravel5/public

so my project is in htdocs/pro/laravel5/ here I have kept above .htaccess else everything is default

when I try to access my project I get following error.

NotFoundHttpException in RouteCollection.php line 145:

in RouteCollection.php line 145
at RouteCollection->match(object(Request)) in Router.php line 719
at Router->findRoute(object(Request)) in Router.php line 642
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

How can I solve this any suggestion, am I missing any things in .htaccess let me know. And I don't want to use second option of moving files and folder.

Jay
  • 821
  • 2
  • 18
  • 50

2 Answers2

0

Hey any way you have to copy .htaccess and index file to your root path then in your htaccess file use public

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

then your index.php thtz all :)

require __DIR__.'/laravel5/bootstrap/autoload.php'; and
$app = require_once __DIR__.'/laravel5/bootstrap/app.php';
Hamelraj
  • 4,676
  • 4
  • 19
  • 42
  • hey move .htaccess, index and web.config files your project path and change the way i mention above i tried for you its working for me – Hamelraj Jul 29 '16 at 09:16
-1

All you have to do is

Rename the server.php in the your Laravel Project Root folder to index.php

Copy the .htaccess file from /public directory to your Laravel root folder.

And that's it now your project will be live in your browser like pro/laravel5/

Iftikhar uddin
  • 3,117
  • 3
  • 29
  • 48
  • trying this option css path is not proper using asset function. – Jay Jul 28 '16 at 08:33
  • css path will work, you have to link it correctly. Put all your assets in Public folder and then link it via {{asset('yourCss.css')}} – Iftikhar uddin Jul 28 '16 at 08:46
  • hey Iftikhar uddin, sorry you get down vote but I didn't do it. I am using asset function only but it is not taking proper path. – Jay Jul 28 '16 at 10:54
  • @user2293790 no i am not saying to you. Can you share the code with us so that i can get idea what is wrong there ? – Iftikhar uddin Jul 28 '16 at 11:16
  • @user2293790 i will suggest you to use virtual hosts which is the best option laravel have. Here is it take a look ( http://stackoverflow.com/questions/37879645/how-to-set-mydomain-com-locally-in-laravel/37879807#37879807 ) – Iftikhar uddin Jul 28 '16 at 11:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/118536/discussion-between-iftikhar-uddin-and-user2293790). – Iftikhar uddin Jul 28 '16 at 11:54