来自 mod_rewrite 的 RewriteRule 仅作为添加了 http://%{HTTP_HOST} 的重定向起作用,但没有它根本不起作用
RewriteRule from mod_rewrite only works as redirect with added http://%{HTTP_HOST}, but doesn't work at all without it
我在 centOs 7 上使用 this apache 配置文件。这个文件已经设置为 运行
/opt/otrs/bin/cgi-bin/customer.pl
在我的机器上调用
http://localhost/opt/customer.pl
我想用 mod_rewrite 到 运行 customer.pl 并给它调用 url 作为参数。
所以我想输入url:
localhost/HTMLData/1/Default.htm
并让它调用:
/opt/otrs/bin/cgi-bin/customer.pl
带参数
?Action=CustomerHTML;Subaction=ContentCall;Target=1/Default.htm
这在某种程度上适用于:
RewriteEngine on
RewriteRule ^/HTMLData/(.*)$ http://%{HTTP_HOST}/otrs/customer.pl?Action=CustomerHTML;Subaction=ContentCall;Target=
但我这是一个重定向(因为添加了“http://%{HTTP_HOST}”)。
我需要的是,网络浏览器一直认为 http://localhost/HTMLData/1/ 是获取文件的位置。
但是如果我删除“http://%{HTTP_HOST}”,它根本不起作用。但是我在网上找到的例子说我应该这样工作。我必须改变什么,只在内部进行重定向而不给浏览器真正的 url 返回?
谢谢
以防将来其他人可能需要它。
为我修复的是添加
RewriteEngine on
RewriteRule ^(.*)$
在“”下。我不知道为什么,但至少我现在可以使用内部重定向了。
我在 centOs 7 上使用 this apache 配置文件。这个文件已经设置为 运行
/opt/otrs/bin/cgi-bin/customer.pl
在我的机器上调用 http://localhost/opt/customer.pl
我想用 mod_rewrite 到 运行 customer.pl 并给它调用 url 作为参数。 所以我想输入url: localhost/HTMLData/1/Default.htm
并让它调用:
/opt/otrs/bin/cgi-bin/customer.pl
带参数
?Action=CustomerHTML;Subaction=ContentCall;Target=1/Default.htm
这在某种程度上适用于:
RewriteEngine on
RewriteRule ^/HTMLData/(.*)$ http://%{HTTP_HOST}/otrs/customer.pl?Action=CustomerHTML;Subaction=ContentCall;Target=
但我这是一个重定向(因为添加了“http://%{HTTP_HOST}”)。 我需要的是,网络浏览器一直认为 http://localhost/HTMLData/1/ 是获取文件的位置。 但是如果我删除“http://%{HTTP_HOST}”,它根本不起作用。但是我在网上找到的例子说我应该这样工作。我必须改变什么,只在内部进行重定向而不给浏览器真正的 url 返回?
谢谢
以防将来其他人可能需要它。 为我修复的是添加
RewriteEngine on
RewriteRule ^(.*)$
在“”下。我不知道为什么,但至少我现在可以使用内部重定向了。