【问题标题】:Combine 2 .htaccess Files合并 2 个 .htaccess 文件
【发布时间】:2011-11-20 02:41:09
【问题描述】:

我有 2 个 .htaccess 文件需要合并在一起。一个由 wordpress 生成,另一个是该站点的现有 .htaccess 文件。 2个文件如下:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301]

RewriteRule ^postreview/$ /viewreview.php [NC,PT,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.*$ ./template2.php  


<IfModule mod_security.c>  
  # Turn off mod_security filtering.  
  SecFilterEngine Off  

  # The below probably isn't needed,  
  # but better safe than sorry.  
  SecFilterScanPOST Off  
</IfModule> 

php_flag session.use_trans_sid off 

wordpress 生成的第二个文件:

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

我尝试了几种方法来组合它们,但要么出现重定向错误,要么出现内部服务器错误。

【问题讨论】:

    标签: wordpress .htaccess mod-rewrite


    【解决方案1】:

    这是我的解决方法:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    
    RewriteBase /
    
    RewriteRule ^postreview(\/?)$ /viewreview.php [QSA,NC,PT,L]
    
    RewriteRule ^projectcars/index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^projectcars/(.*)$ /projectcars/index.php [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*) template2.php [NC,L]
    
    <IfModule mod_security.c>  
     SecFilterEngine Off  
     SecFilterScanPOST Off  
    </IfModule> 
    
    php_flag session.use_trans_sid off 
    

    【讨论】:

      猜你喜欢
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-20
      • 2019-02-06
      • 1970-01-01
      • 2013-05-28
      • 1970-01-01
      相关资源
      最近更新 更多