Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.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
带有可选index.php的动态重写库_Php_.htaccess_Mod Rewrite - Fatal编程技术网

带有可选index.php的动态重写库

带有可选index.php的动态重写库,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我在/us/、/ca/和/fr-ca/上有动态基本URL。使用前面提到的建议重写条件,我能够在大多数情况下使其工作。它工作的情况是,URL中不包含index.php,因此: /us/路径/子路径 /us/path2/子路径 /us/路径/子路径 /us/path2/子路径 对于这些$\u服务器['BASE']将返回/us/ 如果我的应用程序将index.php插入URL,则不再提供BASE 我尝试过使用RewriteCond$0#%{REQUEST_URI}^((?:index.php/)(

我在
/us/
/ca/
/fr-ca/
上有动态基本URL。使用前面提到的建议重写条件,我能够在大多数情况下使其工作。它工作的情况是,URL中不包含index.php,因此:

  • /us/路径/子路径
  • /us/path2/子路径
  • /us/路径/子路径
  • /us/path2/子路径
对于这些
$\u服务器['BASE']
将返回
/us/

如果我的应用程序将
index.php
插入URL,则不再提供
BASE

我尝试过使用
RewriteCond$0#%{REQUEST_URI}^((?:index.php/)([^#]*)#(.*)(.*)1$
,但整个URL返回为
BASE

编辑我现在明白了,通过
^
我告诉htaccess在/directory/之前应该使用index.php。继续挖这里

编辑2

我的虚拟主机文档根指向
/var/www/html
。在/var/www/html中有一个真正的目录,名为
us
。目录
ca
fr-ca
是指向
us
的符号链接

我的htaccess重写ls:

Options +FollowSymLinks
RewriteEngine on

RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=BASE:%2]

你应该在问题中包括conrete RewriteCond+规则,而不仅仅是链接它。此外,这些路径是否可能不仅仅是虚拟路径,而是与实际目录结构重叠?(如果是:取决于重写规则和条件,优先于现有文件。)@anubhava-我更新了我的帖子,解释了我的设置。index.php存在于
/us/
中是。它位于
/us/
我正在转储
$\u服务器
http://test.com/us/index.php/backend1912/some/other/stuff/without/file/extensions/