【问题标题】:.htaccess redirect to same subfolder.htaccess 重定向到同一个子文件夹
【发布时间】:2021-02-19 07:06:24
【问题描述】:

我的问题如下:我的公司与其他人共享托管,我们在“public_html”文件夹中有子域。我可以完美输入我的页面索引,即在www.principal.com/mypage中完美输入。

问题是当我重定向到我的子域中的页面时,它们重定向到主页的 404 Not Found,也就是说 www.principal.com/mypage/new 404 Not Found page of principal.com

主/public_html/.htaccess文件是

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

文件 public_html/mypage/.htaccess 是

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

文件public_html/mypage/public/.htaccess是

<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>

我必须澄清,我的子域直到几天前都运行良好,自 3 月以来运行良好。

Wordpress 是域的主页面,我的子域中的页面是用 Laravel 框架的。 所以,我从 Laravel 重定向到 Laravel whit

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

【问题讨论】:

  • 欢迎来到 Stack Overflow!只是为了澄清一下,自几天前一切正常以来发生了什么变化?你有更新什么吗?你的供应商有吗?
  • 是的,提供商删除了旧的 .htaccess 并使用 Wordpress 创建了另一个,然后我的子域不起作用。您可以在 metalnorsalta.com.ar 中看到作为校长和 www.metalnorsalta.com.ar/autorizaciones/
  • 你好,换一行,它可以反过来工作,子域工作,主页上的链接不工作我改变了: RewriteBase /autorizaciones 我需要 auto_awesome Quizás quisiste decir: necesito que ambos funcionan 28 / 5000 Resultados de traducción 我需要同时工作

标签: wordpress laravel .htaccess subdomain


【解决方案1】:

我解决了 我更改了文件 public_html/mypage/.htaccess 是

<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>

【讨论】:

    【解决方案2】:

    您的问题是因为使用了根级别 .htaccess 中的指令,即使某些内容可能被定向到子文件夹中的站点。在 public_html/.htaccess 中尝试这样的操作,以排除发送到子文件夹的请求:

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

    【讨论】:

    • 是的,就是这样,但知道 Not Found 在此服务器上找不到请求的 URL /autorizaciones/tfc/18109。
    • 你好,换一行,它可以反过来工作,子域工作,主页上的链接不工作我改变了: RewriteBase /autorizaciones 我需要 auto_awesome Quizás quisiste decir: necesito que ambos funcionan 28 / 5000 Resultados de traducción 我需要同时工作
    猜你喜欢
    • 2013-02-01
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 2015-10-06
    • 1970-01-01
    相关资源
    最近更新 更多