Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.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代码重定向到XAMPP索引页_Php_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php Htaccess代码重定向到XAMPP索引页

Php Htaccess代码重定向到XAMPP索引页,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,我正在尝试编写htaccess代码,将直接链接文件(例如图像和css文件)之外的所有URL重定向到index.php文件进行处理 http://localhost/testsite/login 重定向到 http://localhost/testsite/index.php?cmd=login 但是htaccess代码将我重定向到XAMPP主页。这是我的密码 DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FI

我正在尝试编写htaccess代码,将直接链接文件(例如图像和css文件)之外的所有URL重定向到index.php文件进行处理

http://localhost/testsite/login
重定向到

http://localhost/testsite/index.php?cmd=login
但是htaccess代码将我重定向到XAMPP主页。这是我的密码

DirectoryIndex index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?cmd=$1  [QSA,NC,L]

我做错了什么?

从目标中删除
/
,并使用适当的
重写库

DirectoryIndex index.php
RewriteEngine on
RewriteBase /testsite/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?cmd=$1  [QSA,L]

/index.php
将其路由到当前目录中的站点根
index.php
,而不是
index.php

重写库/testsite/