0

So basically my site was pre-made so that pages did not exist. The only features that existed was a directory and some posts. No pages. So I had to duplicate the posts function (meaning I replaced all instances of $post and $posts with $page and $pages). It all worked fine. I created a test page which worked. But now I can't access my backend.

This is the URL structure of the pages as seen in the routes file:

    Route::get('{url}', 'postsController@viewpage');

So it will basically look like this: www.mywebsite.com/pagehere

But the backend's URL structure looks like this: www.mywebsite.com/admin

So I wonder if my page structure is conflicting with the admin backend?

Whenever I try to access the backend, I get redirected to the homepage.

My controller file has this:

    public function adminpage(){
        return view ('admin/index')->with("title","Admin");
    }
Thomas
  • 101
  • 2
  • 13

1 Answers1

0

Seems like the rule you put in place matches every route:

Route::get('{url}', 'postsController@viewpage');

You need to specify that the given url must exclude routes tarting with admin, via a regex you can achieve this:

Route::get('{url}', 'postsController@viewpage')->where('url', '[^admin]');

Also I would advise you to use appropriate naming convations: PostsController

Laravel route regex docs

ka_lin
  • 9,329
  • 6
  • 35
  • 56
  • ok so I can access the admin backend but now the test page broke and says Under Construction. The URL structure was: example.com/test – Thomas Mar 30 '18 at 07:24
  • Maybe it's in [maintenance](https://laravel.com/docs/5.6/configuration#maintenance-mode) mode? – ka_lin Mar 30 '18 at 07:25
  • You said it was "premade", a platform which is based on Laravel? Existing project? a plugin added in Laravel? Maybe there is an option via a config? Find where the template is requested and work upwards...not much to say being in the dark – ka_lin Mar 30 '18 at 07:32
  • yes, it is based on Laravel. There are lots of pages that have similar URL structure. eg: /admin/, /articles/, /user/, /schools/. – Thomas Mar 30 '18 at 07:40