0

I have installed wordpress on a sub folder (sricargo-blog) inside the laravel installation folder. I want to redirect to that wordpress folder(admin panel of wordpress) when user click on /wp-blog url. I get this 404 page not found error everytime I go to that url.

This is the directory structure

  • sricargo
    • app
    • bootstrap
    • config
    • database
    • public
    • resources
    • sricargo-blog
    • storage
    • tests
      ..
      ..
      ..
      ..
      Other laravel files

This is my route in web.php

Route::get('/wp-blog', function () {
return Redirect::to('sricargo-blog');
});

.htaccess file in public folder

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

RewriteEngine On

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

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

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /../sricargo-blog/index.php/$1 [L]
</IfModule>

What am i doing wrong ? Is there a better way to do this ?

3
  • After you have rewritten everything that does not match an existing file or folder to the index.php with the lines following # Handle Front Controller..., you can’t expect the same thing to happen again in the lines below that. If anything, you need to do this the other way around - more specific rewrites first, more general ones later. But I really doubt whether this kind of setup makes sense to begin with, I’d expect that could cause other routing-related issues as well.
    – CBroe
    Mar 19, 2018 at 9:27
  • move sricargo-blog folder to your public directory, the it will be accessible directly by domain.com/sricargo-blog Mar 19, 2018 at 9:30
  • Anything available publicly should go to Laravel's public folder
    – brombeer
    Mar 19, 2018 at 9:32

1 Answer 1

0

You can directly do it using .htaccess, no need to give route in laravel. In your .htaccess file put this code.

RewriteEngine On

Options Indexes FollowSymLinks

RewriteBase /wp-blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /../sricargo-blog/index.php/$1 [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.