0

Hi I am facing issues with settng pretty urls withput public in url but it is not working for me.

I already tried

Laravel 5.2 Pretty URLs, Laravel 5 - Remove public from URL

and more similar urls but nothing seems to work for me.

I am using wamp, windows 8

I have make sure mod_rewrite is on, and is working properly.

Here is my htaccess on root.

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

my htaccess in test inside public folder

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

I have also tried pasting the htacess from public folder on root folder and removed the one from public folder but it dint work

actually the error which occurs is that my routes file skips all the patterns say if I have something like Route::get('/api/login', 'api@login') then it does works with urls containing public but when I remove public from url all the patterns are skipped. and it shows 404

I made sure all the requests are reaching public/index.php and mysterious thing is that when I print

var_dump(Request::root());

in routes.php it for url with public it says http://localhost/folderName/subFolderName/public but for the urls without public it says http://localhost/ and I think this is the reason why my patterns in routes file are not working.

P.S. I have set the title pretty urls laravel 5.4 instead of laravel routes not working because I think it is .htaccess which I needs to configure properly to get this working.

I do not want to change the folder structure because I believe in that there is some reason for which it is like this and There should be some work around for this.

Regarding setting vhosts I wont be able to do this on server (For I do not have the rights) so there is no use of setting a vhost on local as a work around as in login run I have to solve this.

Community
  • 1
  • 1
Arpita
  • 1,386
  • 1
  • 15
  • 35

1 Answers1

0

Try this in your public/.htaccess

RewriteRule ^ /public/index.php [L]

And the .htaccess in root

RewriteRule ^(.*)$ /public/$1 [L]
stef
  • 26,771
  • 31
  • 105
  • 143
  • Stef, Thanks for taking out time to reply this but this gives me 404 on both the urls i.e url with and without public in it. – Arpita Apr 10 '17 at 05:40
  • 1
    Assuming it says it can't find index.php, try to change the path to index.php in your htaccess file, that fixed it for me. First try to remove index.php, then public. Don't mess with both htaccess files at the same time, it will get confusing. – stef Apr 10 '17 at 09:37