0

I have tried almost all the solutions on internet regarding this issue.

I have moved my Laravel project from Windows 10 to linux CentOS 6. I tried to change project structure in two different manner but both face the issue.

I am trying to remove index.php from [www.example.com]/index.php/[routes url]. I don't have access to root or sudo command as this project is being installed in University server. But I can request IT admin for tasks that require root access.

I am currently in /home/cs4/username (folder). My current project structure is:

blog (folder)
 - contains all the Laravel framework files other than public folder

 public_html (folder)
 - contains all the files of laravel public folder plus 
 - .htaccess file created

.htaccces file contains below code:

 # Redirect Trailing Slashes...
 #RewriteRule ^(.*)/$ $1 [L,R=301]

 RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
 RewriteCond %{REQUEST_URI} !/system/.* [NC]
 RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

 # Handle Front Controller...
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 #RewriteRule ^ index.php [L]
 RewriteRule ^(.*)$ /index.php/$1 [L]

I have replaced 2 lines of index.php file which is in public_html folder

from these

require __DIR__.'/../bootstrap/autoload.php';
 $app = require_once __DIR__.'/../bootstrap/app.php';

to

 require __DIR__.'/../blog/bootstrap/autoload.php';
 $app = require_once __DIR__.'/../blog/bootstrap/app.php';

Issue is that http://example.ac.uk/~username/ loads the project but for all other url's I have to add index.php for example: http://www.example.ac.uk/~username/index.php/login instead of http://www.example.ac.uk/~username/login similarly for all other url's.

I also tried to put entire project inside public_html folder, the directory structure was:

public_html
 -entire project files and folders
 -public folder

but then 2 issues:

all the server files like : .env and other code is exposed causing security risk

I am forced to have public/index.php in the url.

for example: http://www.example.ac.uk/~username/public/index.php/login instead of http://www.example.ac.uk/~username/login similarly for all other url's.

Murlidhar Fichadia
  • 2,589
  • 6
  • 43
  • 93
  • Do you find the solution? – Michel Jan 08 '18 at 11:11
  • @Michel it had to do with .htaccess I am not sure what made it work. All I remember is I had to setup Virtual Host somewhere in linux folders and then I took out public folder from laravel project and placed it next to the project folder. like: `public folder and myApp folder` also I had to change a url in server.php file to point public folder outside the project folder. public folder is then given full access Read Write and Execute 775 Chmod to all files and folders inside public – Murlidhar Fichadia Jan 08 '18 at 13:03
  • I'm stucked with the same! It will be helpful if you share what you have done.. – Michel Jan 08 '18 at 13:05
  • 1
    @Michel these were the steps : https://stackoverflow.com/questions/23837933/how-can-i-remove-public-index-php-in-the-url-generated-laravel – Murlidhar Fichadia Jan 08 '18 at 13:08
  • @Michel allow override all works. for info on VirtualHost check `smcjones` solution in the same link I shared – Murlidhar Fichadia Jan 08 '18 at 13:09
  • I have to check it out. May be I could find a solution... – Michel Jan 08 '18 at 13:18

0 Answers0