【问题标题】:Subfolder .htaccess redirecting to root folder子文件夹 .htaccess 重定向到根文件夹
【发布时间】:2015-10-06 14:57:41
【问题描述】:

这是我的根文件夹 .htaccess

Options +FollowSymLinks
Options -Indexes

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.net/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.domain.net/$1 [R=301,L]

</IfModule>

这是我的子文件夹 .htaccess

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} /admin/?$
RewriteRule ^(.*)$ %1/Admin/index.php [NE,R,L]
RewriteCond %{REQUEST_URI} /Admin/?$
RewriteRule ^(.*)$ %1/Admin/index.php [NE,R,L]

RewriteCond %{REQUEST_URI} /stores/?$
RewriteRule ^(.*)$ %1/Stores/ [NE,R,L]

RewriteCond %{REQUEST_URI} /categories/?$
RewriteRule ^(.*)$ %1/Categories/ [NE,R,L]

# working with client side
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ index.php?qstr=$1 [QSA,L]
RewriteRule ^coupons/(.*)$ index.php?qstr=coupons/$1 [QSA,L]
RewriteRule ^(.*)/$ index.php?qstr=$1 [QSA,L]

</IfModule>

我的问题是,当我尝试访问时

http://domain.net/coupon-website/admin

我被重定向到

https://www.domain.net/Admin/index.php

而不是

https://www.domain.net/coupon-website/Admin/index.php

我错过了什么?为什么我被重定向到根文件夹而不是优惠券网站子文件夹?

【问题讨论】:

    标签: php apache .htaccess mod-rewrite redirect


    【解决方案1】:

    经过反复试验,我终于找到了解决方案。 这是我的新子文件夹 .htaccess,现在可以按预期工作。

    <IfModule mod_rewrite.c>
    
    RewriteCond %{REQUEST_URI} /admin/?$
    RewriteRule ^(.*)$ %1/coupon-website/Admin/index.php [NE,R,L]
    RewriteCond %{REQUEST_URI} /Admin/?$
    RewriteRule ^(.*)$ %1/coupon-website/Admin/index.php [NE,R,L]
    
    RewriteCond %{REQUEST_URI} /stores/?$
    RewriteRule ^(.*)$ %1/coupon-website/Stores/ [NE,R,L]
    
    RewriteCond %{REQUEST_URI} /categories/?$
    RewriteRule ^(.*)$ %1/coupon-website/Categories/ [NE,R,L]
    
    # working with client side
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]*)$ index.php?qstr=$1 [QSA,L]
    RewriteRule ^coupons/(.*)$ index.php?qstr=coupons/$1 [QSA,L]
    RewriteRule ^(.*)/$ index.php?qstr=$1 [QSA,L]
    
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多