简体   繁体   English

.htaccess RewriteRule加上httpd.conf ScriptAliasMatch

[英].htaccess RewriteRule plus httpd.conf ScriptAliasMatch

I have been adding 301 redirects successfully into our site .htaccess file, so that I can point url's from our old site to the correct url's on our new site, however I cannot get any redirects to work where the old url contains a ".pgm". 我已成功将301重定向成功添加到我们的站点.htaccess文件中,以便可以将旧站点中的url指向新站点上的正确url,但是在旧URL包含“ .pgm”的情况下,我无法进行任何重定向”。

The ".pgm's" are RPG programs on our IBM iSeries server, and the url's on the new site are redirected in the httpd.conf file as follows: “ .pgm”是我们IBM iSeries服务器上的RPG程序,新站点上的url在httpd.conf文件中重定向,如下所示:

ScriptAliasMatch (.*)\.pgm$ /QSYS.LIB/B2CRLIVE.LIB/$1.pgm

All of the url redirects for both vanity links and for url's from the old site are done in .htaccess, and these work fine, unless the old url contains ".pgm", in which case no matter what I try to do I end up with a 404 page. 虚荣链接和旧站点中所有url的所有url重定向都在.htaccess中完成,并且这些工作正常,除非旧url包含“ .pgm”,在这种情况下,无论我做什么,最终404页。

An example of the old site url is: 旧网站网址的示例是:

http://mydomain/b2c/b2chome.pgm

The redirect I am using is: 我正在使用的重定向是:

RewriteRule b2chome /category/0/Product\ Range [R=301,L]

This works fine if the url is: 如果网址为:

http://mydomain/b2c/b2chome

but once you add ".pgm" to any url it just results in a 404 page. 但是,一旦您将“ .pgm”添加到任何网址,它只会导致404页面。

The ScriptAliasMatch works for pointing ".pgm's" to the correct program library, but the programs used on the old site don't exist in the library which is being pointed at. ScriptAliasMatch可以将“ .pgm”指向正确的程序库,但是旧站点中使用的程序在所指向的库中不存在。 I don't think this is the problem though, because I think if it was I would get a script error of some kind. 我不认为这是问题所在,因为我认为如果是这样的话,我会收到某种脚本错误。

Any ideas please? 有什么想法吗?

I did find a solution, albeit not the one I was looking for. 我确实找到了解决方案,尽管不是我要找的解决方案。 I added a redirect into the httpd.conf file, above the ScriptAliasMatch as follows: 我在ScriptAliasMatch上方的httpd.conf文件中添加了重定向,如下所示:

Redirect 301 /b2c/b2chome.pgm http://www.domain.com/category.pgm

This at least works, even though I can now only place the non-pgm redirects in the .htaccess file. 即使我现在只能将非pgm重定向放置在.htaccess文件中,这至少也可以工作。 The .pgm redirects are at least limited in number, whereas I keep finding non-pgm links from the old site that are being referenced from somewhere, often old links on forums. .pgm重定向的数量至少是有限的,而我一直在寻找旧站点中非pgm链接,这些链接是从某个地方引用的,通常是论坛上的旧链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM