1

I have .htaccess file in shared hosting:

<IfModule mod_rewrite.c>

  RewriteEngine on

  RewriteCond %{REQUEST_URI} !^public

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

It is working fine foor all routes, except for cms My web.php route file is:

Route::get('/', 'HomeController@index')->name('home');
Route::get('/home', 'HomeController@index');
Route::get('/menu', 'HomeController@menu')->name('menu');
Route::get('/reservation', 'HomeController@reservation')->name('reservation');
Route::get('/gallery', 'HomeController@gallery')->name('gallery');
Route::get('/contact', 'HomeController@contact')->name('contact');
Route::get('/about', 'HomeController@about')->name('about');

Auth::routes();

Route::prefix('admin')->name('admin.')->namespace('Admin')->group(function () {
    Auth::routes();
    Route::middleware('auth:admin')->group(function () {
        Route::get('/', 'AdminController@index')->name('home');
        Route::match(array('GET', 'POST'), '/gallery/{gallery?}/{action?}', 'AdminController@gallery')->name('gallery');
        Route::match(array('GET', 'POST'), '/{controller}/{action?}/{id?}', 'AdminController@crud')->where('id', '[0-9]+')->name('crud');
    });    
});

It works well on my local server, but, any url with /admin automatically goes through /public folder in my web server.

My question is how to prevent this from happening using .htaccess?

Edit: It happens only when redirected by auth. eg. if /admin then it redirects to login as /public/admin ALso, I just found out that, I cannot POST anything from cms it gives 403 error. It works fine on localhost.

priosshrsth
  • 1,070
  • 2
  • 11
  • 30

1 Answers1

1

You should add the following lines to your conf,

<Directory /var/www/html/project/public>
        AllowOverride All
</Directory>

I hope this will help

webdevtr
  • 480
  • 2
  • 6
  • Sorry, but where is this conf file. I am using reseller hosting and using it to host all my projects. – priosshrsth Jun 13 '18 at 05:02
  • please check for this, https://stackoverflow.com/questions/18740419/how-to-set-allowoverride-all – webdevtr Jun 13 '18 at 06:55
  • Ok, thank you all for your answers. The problem is solved, but, I am not sure how. The problem is only on those projects that were hosted in sub domain. So, after moving the project to its own domain, it works as expected. – priosshrsth Jun 15 '18 at 17:38