htaccess RewriteRule redirecting to parent directory?

后端 未结 3 959
一向
一向 2020-12-19 05:17

I cant understand how to redirect to the parent directory in this case: I have a root directory with .htaccess file, where rewriteEngine is on. In this directory I have a fi

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 05:56

    You wrote:

    When there is request to "forum.mySite.com/rootFile.php", I need to redirect it to "mySite.com/rootFile.php" which means I need to redirect request to the parent directory.

    Did you mean:

    When there is request to "mySite.com/forum/rootFile.php", I need to redirect it to "mySite.com/rootFile.php" which means I need to redirect request to the parent directory.

    ...Which in turn means:

    When there is request to "/forum/rootFile.php", I need to redirect it to "/rootFile.php" which means I need to redirect request to the parent directory.

    In your .htaccess in the /forum dir try this:

    RewriteEngine On
    RewriteRule ^rootFileName(.*) /rootFile.php  [QSA,R=301,L]
    

提交回复
热议问题