Search code examples
wordpresslaravel.htaccesssubdomain

.htaccess redirect to same subfolder


My problem is the following: My company shares hosting with others, and we have the subdomain inside a "public_html" folder. I can enter the index of my page perfectly, that is in www.principal.com/mypage it enters perfectly.

The problem is when I redirect to pages within my subdomain, they redirect to the 404 Not Found of the main page, that is to say www.principal.com/mypage/new 404 Not Found page of principal.com

The main / public_html / .htaccess file is

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

The file public_html/mypage/.htaccess is

<FilesMatch ".(phtml|php|PhP|php5|suspected)$">
Order Allow,Deny
Allow from all
</FilesMatch>

The file public_html/mypage/public/.htaccess is

<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 must clarify that my subdomain worked perfectly until a few days ago, since March that it worked very well.

Wordpress is the main page of the domain, my page in the subdomain is with the Laravel framework. So, I redirect from Laravel to Laravel whit

Route::group([
    'middleware' => 'auth'],
    function(){
        Route::get('/onepage', 'HomeController@one');
        Route::get('/twopage', 'HomeController@two'); 
});

Solution

  • I solved it I changed The file public_html/mypage/.htaccess is

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /MYPAGE
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    </IfModule>