Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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
Php 将多个URL作为一个页面加载_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 将多个URL作为一个页面加载

Php 将多个URL作为一个页面加载,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,不是100%确定如何,但我知道它很简单。但我不知道该怎么做 基本上,我希望它加载index.php文件,无论它们在包含index.php的文件夹中指向哪个url,例如: 将在名为folder的文件夹中加载:index.php。无论加载了什么/folder/file.php,都会发生这种情况 谢谢 试试这个: RewriteEngine on #Rewrite "folder/file" #don't rewrite "folder/index.php" Rewritecond %{REQUES

不是100%确定如何,但我知道它很简单。但我不知道该怎么做

基本上,我希望它加载index.php文件,无论它们在包含index.php的文件夹中指向哪个url,例如: 将在名为folder的文件夹中加载:index.php。无论加载了什么/folder/file.php,都会发生这种情况

谢谢

试试这个:

RewriteEngine on

#Rewrite "folder/file"
#don't rewrite "folder/index.php"
Rewritecond %{REQUEST_URI} !/index.php$
 RewriteCond %{REQUEST_URI} ^/([^/]+)/[^.]+(\.php|html)?$
RewriteRule ^ /%1/index.php [NC,L]
这重写了

 http://example.com/foo/bar.php


我明白这不仅仅是简单的重定向,对吧?工作非常完美,只是添加了一些修改,删除了/%1/和/([^/]),因为我在我称为games的特定文件夹中拥有htaccess。只有一件事,我如何使它改变,例如:to(当然,确保最后一个/不需要,因为它只是一个尾随斜杠)。对不起,我在最后一个规则中添加了一个错误的路径。查看编辑最后一条规则不是问题,而是最后一个条件。它检查/folder/file“.php/html”而不仅仅是/folder/file
 http://example.com/foo/index.php