2014-10-17 122 views
-1

我想重定向3頁,但由於某種原因,它似乎並沒有工作。網站建立與ASPasp htaccess 301重定向

<IfModule mod_rewrite.c> 

    # Make sure directory listing is disabled 
    Options +FollowSymLinks -Indexes 
    RewriteEngine on 

    # Re-write for PDFs requests not pre-pended with /pdf/ I.E. in the root - prepend /pdf/ - Use negative look-ahead - If the file doesn't exist you get a 500 though sadly. 
    RewriteCond %{REQUEST_URI} ^/(?!pdf/)(.*)\.(pdf)$ 
    RewriteCond %{DOCUMENT_ROOT}/pdf/$1 -f 
    RewriteRule ^(.*)$ /pdf/$1 [L] 

    # If the URI is not in /images,/pdf,/css, or /js let the handler process it 
    RewriteCond %{REQUEST_URI} !^(/images/|/pdf/|/css/|/js/) 
    RewriteCond %{REQUEST_FILENAME} !handler.php 
    RewriteRule ^(.*)$ handler.php/$1 [L] 

    # If the URI IS in the above directories but the file doesn't exist run it through the handler as well 
    RewriteCond %{REQUEST_URI} ^(/images/|/pdf/|/css/|/js/) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ handler.php/$1 [L] 

    # Permanent URL redirect 
    Redirect 301 /Server_Rack_Cabinet_RS_42U.asp http://www.rackmountsolutions.net/cruxial-core-1000-series-server-rack.asp 
    Redirect 301 /Sound_Dampening_Proof_Server_Rack.asp http://www.rackmountsolutions.net/AcoustiQuiet_Soundproof_Server_Rack.asp 
    Redirect 301 /Relay_Rack_4_post.asp http://www.rackmountsolutions.net/4_Post_Server_Rack.asp 

</IfModule> 

#永久URL重定向部分似乎不工作。以上是我在.htaccess文件中的完整代碼。

+0

'Redirect'指令由'mod_alias'提供:https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect – hjpotter92 2014-10-17 18:25:36

回答

1

由於此站點在IIS服務器上運行,因此有一個web.config文件以某種方式無視了.htaccess文件。看看我是怎麼做到的。 web.config文件位於我的網站的根文件夾中。

<configuration> 
    <system.webServer> 
     <rewrite> 
    <rules> 

     <rule name="Env-leader-redirect1" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="^Server_Rack_Cabinet_RS_42U.asp" /> 
     <conditions> 
      <add input="{HTTP_HOST}" pattern="^www\.rackmountsolutions\.net$" /> 
     </conditions> 
     <action type="Redirect" url="http://www.rackmountsolutions.net/cruxial-core-1000-series-server-rack.asp" /> 
    </rule> 

    <rule name="Env-leader-redirect2" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="^Server_Rack_Cabinet_RS_42U.asp" /> 
     <conditions> 
      <add input="{HTTP_HOST}" pattern="^www\.rackmountsolutions\.net$" /> 
     </conditions> 
     <action type="Redirect" url="http://www.rackmountsolutions.net/cruxial-core-1000-series-server-rack.asp" /> 
    </rule> 

    </rules> 
    </rewrite> 
</system.webServer> 
</configuration>