我正在尝试重定向3个页面,但出于某种原因,它似乎无法正常工作。网站是用asp构建的
<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>
#Permanent URL重定向部分似乎不起作用。以上是我在.htaccess文件中的完整代码。
答案 0 :(得分: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>