我希望非 IIS 人员可以帮助我解决这个问题,尽管我遇到的问题是基于运行 ISAPI_Rewriter 的 IIS6 服务器。
情况是我在 IIS6 上运行 Wordpress,ISAPI_Rewriter 被用作 mod_rewrite 的替代品,并且运行正常。我的问题是,当我让它为 Wordpress 重写我的 URL 时(所以我不需要其中的 index.php 文件名)它显示 404。经过大量搜索,我发现问题是因为 ASP.net 的一部分(或类似的东西)正在将 eurl.axd/[random string] 添加到 URL 的末尾,因此这被输入到 Wordpress 请求中并破坏了它。我将 Wordpress 模板设置为输出请求的 URL,它看起来像这样:
http://www.example.com/index.php/about/eurl.axd/b552863f2d5e9841b5d8b79b44ac02e8/
我相信这是因为 IIS 系统中各种事物的优先顺序,而罪魁祸首需要运行项目的另一部分。我更愿意继续使用 ISAPI_Rewriter 来美化 URL,所以我想知道这一点:
有没有办法让 mod_rewrite 在将它输入系统之前删除 eurl.axd/[string] ?
我的 .htaccess 文件目前显示如下:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# The following line excludes folders from rewriting
RewriteCond %{REQUEST_URI} !^/folder-name/
RewriteRule ^/(.*)$ /$1 [NC,L]
感谢您提供的所有帮助,我们始终不胜感激。
编辑:根据建议调整了我的 htaccess,从我进行的简短测试来看,它似乎运行良好。已经贴在下面了。
RewriteEngine on
RewriteBase /
# This is used to strip ASP.net eurl.axd bits
# from the URL so wordpress can use permalinks
# For the root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^eurl\.axd/[0-9a-f]+/$ index.php [NC,L]
# For internal permalinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)/eurl\.axd/[0-9a-f]+/$ index.php/$1 [NC,L]