Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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 .htaccess重写每个URL_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php .htaccess重写每个URL

Php .htaccess重写每个URL,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我希望.htaccess将每个文件/目录发送到我的index.php。到目前为止,我有: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ index.php?urlparam=$1

我希望
.htaccess
将每个文件/目录发送到我的
index.php
。到目前为止,我有:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{REQUEST_FILENAME} -d 

RewriteRule ^(.*)$ index.php?urlparam=$1 [NC,L] 

但如果目录存在,则在mysite.com/foobar上会出现此错误:

禁止的

您没有访问此文档的权限

如果没有:

找不到

在此服务器上找不到请求的文档。(404)


同时具有
-f
-f
条件集毫无意义。这基本上是说:

如果请求与现有文件不匹配,并且请求也与现有文件匹配,请执行此重写规则

显然,你不能两者兼得

你想要的只是:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.php?urlparam=$1 [NC,L] 
(对我来说)不清楚您是否希望文件或目录的URL(即使它们存在)通过index.php路由