【问题标题】:htaccess https://example.com/dash/something link redirect problemhtaccess https://example.com/dash/something 链接重定向问题
【发布时间】:2020-04-17 05:30:44
【问题描述】:

我有一些目录:

/
/dash
/something

我想让 htaccess 将所有流量重定向到它的子文件夹 index.php ,我这样做了,当我输入它时 example.com/dash 或 example.com/something

但我的问题是当我尝试类似 example.com/dash/login 或 example.com/dash/another 在这种情况下,我被重定向到 / 目录

这是我在 / 目录中的 htaccess

https://we.tl/t-NtTDlYKBHr

Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!dash/)(.+)$ /index.php?u=$1 [NC,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^dash/(.+)$ /dash/index.php?u=$1 [NC,QSA,L]

在 /dash

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

https://we.tl/t-lhgQ03tTGE

【问题讨论】:

    标签: php apache .htaccess xampp


    【解决方案1】:

    我不是这方面的专家。但我认为你可以通过这样的方式实现它。
    将此文件放在您的父目录中

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^none/ none/index.php [NC,L,QSA]
    RewriteRule ^dash/ dash/index.php [NC,L,QSA]
    RewriteRule ^something/ something/index.php [NC,L,QSA]
    RewriteRule ^ index.php [NC,L,QSA]
    

    如果你把 htaccess 放在每个目录中,你可以在所有目录中使用它。

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [NC,L,QSA]
    

    【讨论】:

    • 不,它不起作用:/ localhost/dash/rame 再次重定向到 /-s index.php
    • 您在每个目录中都使用 .htaccess 吗?
    • 是的,在每个目录中
    • 您需要从其他目录中删除其他.htaccess
    • 我删除了,现在 localhost/dash 重定向到 /-s index.php
    猜你喜欢
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2018-05-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多