Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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:重定向有效,但重写无效';T_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache .htaccess:重定向有效,但重写无效';T

Apache .htaccess:重定向有效,但重写无效';T,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,我想将URL从目录B重写为A 在目录B的.htaccess中重写规则 RewriteRule ^(.*)$ /A/xyz [NC,L] 在目录A的.htaccess中重写规则 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php 在我点击example.com/B/index.php时执行此操作后,将呈现index.php的结果。 然而,当我将重写

我想将URL从目录B重写为A

在目录B的.htaccess中重写规则

RewriteRule ^(.*)$ /A/xyz [NC,L]
在目录A的.htaccess中重写规则

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule . index.php
在我点击example.com/B/index.php时执行此操作后,将呈现index.php的结果。 然而,当我将重写更改为重定向时

RewriteRule ^(.*)$ /A/xyz [NC,L,R] 
它被正确重定向到example.com/A/xyz


重写错误地呈现index.php。我想在点击example.com/B/时呈现example.com/A/xyz。使用我当前的重写模式和替换只有在我向重写添加[R]标志时才有效。我不想重定向,我只想在内部重写到指定的替换。

因为第一个版本已经完成了您想要的,您有什么问题吗?您应该删除此页面上的php标记question@OlafDietsche第一个版本错误地呈现index.php。我想在点击example.com/B/时呈现example.com/A/xyz。使用我当前的重写模式和替换只有在我向重写添加[R]标志时才有效。我不想重定向,我只想在内部重写到指定的替换。这不应该发生。当
/A/xyz
是真实文件时,将不使用
index.php
。可能父目录中的另一个规则或.htaccess文件跳入。@OlafDietsche是否可能父目录或另一个规则只影响重写而不影响重定向?因为第一个版本已经满足了您的要求,你的问题是什么?你应该删除这个页面上的php标签question@OlafDietsche第一个版本错误地呈现index.php。我想在点击example.com/B/时呈现example.com/A/xyz。使用我当前的重写模式和替换只有在我向重写添加[R]标志时才有效。我不想重定向,我只想在内部重写到指定的替换。这不应该发生。当
/A/xyz
是真实文件时,将不使用
index.php
。父目录中可能跳入另一个规则或.htaccess文件。@OlafDietsche是否可能父目录或另一个规则只影响重写而不影响重定向?