首页 文章

使用htaccess重定向整个目录

提问于
浏览
0

我无法弄清楚为什么我的重定向不能正常工作,因为它们在另一个htaccess文件中 .

我正在尝试将旧网址重定向到新网址 .


RewriteEngine on
AddDefaultCharset UTF-8

DirectoryIndex index.php index.html
<IfModule mod_php.c>
php_flag magic_quotes_gpc off
</IfModule>

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule (.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1

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

Redirect /private_3 http://website.com/new_private

我尝试过各种各样的东西,我在网上找到但没有任何作用 .

请帮忙 .

谢谢 .

2 回答

  • 0

    看起来糟糕的订单和 mod_aliasmod_rewrite 混合可能是一个问题 . 尝试重新排序您的规则:

    AddDefaultCharset UTF-8
    
    DirectoryIndex index.php index.html
    <IfModule mod_php.c>
       php_flag magic_quotes_gpc off
    </IfModule>
    RewriteEngine on
    
    RewriteRule ^private_3 http://website.com/new_private [L,R=301,NC]
    
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    
    RewriteRule ^(system.*)$ index.php?/$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1
    
  • 0

    而不是使用这个:

    Redirect /private_3 http://website.com/new_private
    

    尝试在 RewriteEngine on 行下方添加此内容:

    RewriteRule ^private_3(.*)$ http://website.com/new_private$1 [L,R=301]
    

相关问题