Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache .htaccess-路由到所选目的地,但更改浏览器url_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache .htaccess-路由到所选目的地,但更改浏览器url

Apache .htaccess-路由到所选目的地,但更改浏览器url,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,问题: 我想接受最初的要求。说它是,/IWantToGoHere/index.php 但是我想回到浏览器,/GoHere/index.php 需要说明的是: 实际上,我希望将原始请求位置发送到请求的脚本,但是,我希望将浏览器URL返回给用户到另一个目标 代码: 注: 我意识到上面的代码不起作用。我试过很多不同的电话。昨天我花了无数个小时尝试从有限的mod_rewrite知识库中找到的每一个聪明的解决方案。根据我对mod_rewrite的理解,我认为这是不可行的。我知道这不是预处理的目的。至少我在

问题: 我想接受最初的要求。说它是,/IWantToGoHere/index.php 但是我想回到浏览器,/GoHere/index.php

需要说明的是:
实际上,我希望将原始请求位置发送到请求的脚本,但是,我希望将浏览器URL返回给用户到另一个目标

代码:

注: 我意识到上面的代码不起作用。我试过很多不同的电话。昨天我花了无数个小时尝试从有限的mod_rewrite知识库中找到的每一个聪明的解决方案。根据我对mod_rewrite的理解,我认为这是不可行的。我知道这不是预处理的目的。至少我在Apache网站上找不到任何东西。有人告诉我,如果我能想出一个办法,就一定能做到:)我想知道是否有人有办法让它发挥作用

你为什么要这么做 因为我知道。不,真的,我想把URL返回给用户进行进一步处理


weez

如果我正确理解了这个问题,那么要完成这个任务,您需要从
/iwanttoghere/index.php
发送一个头,在脚本执行完毕后重定向到
/GoHere/index.php
。也就是说,如果您希望Apache仍然调用
IWantToGoHere
,但返回到
GoHere
。因此,在
iwanttohere
的处理结束时,编写如下脚本:

header('Location:/GoHere/Index.php')


这将正确重定向

皮博雷1:是的,我想你会明白我的意思。隐马尔可夫模型。。。我没有想到这一点。我想只要我的控制器(我使用的是MVC模式)发送了任何输出头,这就可能工作。让我试一试。谢谢你的想法。幸好控制器不是视图,所以不应该输出任何内容。我建议你重新考虑你的URL模式。提出一个好的“公共”URL模式,并使用mod_rewrite将其重写为“内部”模式。你说的是疯狂。你不需要逃避
/
角色;Apache不使用类似Perl的分隔符。但是需要转义
RewriteEngine on
RewriteRule ^(.*)IWantToGoHere\/\.php$  GoHere/index.php [NC,C]
RewriteRule ^GoHere/index.php$ GoHere/index.php [R,NC]