Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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站点在localhost:8000上正确运行,但在XAMPP或其他服务器上提供错误报告。如何创建.htaccess?_Php_.htaccess - Fatal编程技术网

PHP站点在localhost:8000上正确运行,但在XAMPP或其他服务器上提供错误报告。如何创建.htaccess?

PHP站点在localhost:8000上正确运行,但在XAMPP或其他服务器上提供错误报告。如何创建.htaccess?,php,.htaccess,Php,.htaccess,这是我第一次使用PHP创建网站。 我的项目在php interne服务器上运行正常,但在服务器ovh上的Xampp ni上运行不正常 ovh serveur erreur:App\Router::run():无法打开必需的“/home/myla/www/views/.php”(include_path=”:/usr/share/php):var$view false localhost:8000工作正确:var$view post/index XAMPP erreur:正在尝试访问类型为bool

这是我第一次使用PHP创建网站。 我的项目在php interne服务器上运行正常,但在服务器ovh上的Xampp ni上运行不正常

ovh serveur erreur:App\Router::run():无法打开必需的“/home/myla/www/views/.php”(include_path=”:/usr/share/php):var$view false

localhost:8000工作正确:var$view post/index

XAMPP erreur:正在尝试访问类型为bool的值的数组偏移量: var$view false

问题出在函数run()的var$视图中

我在index.php中使用run()

$router = new App\Router(dirname(__DIR__) . '/views');
$router
->get('/', 'post/index', 'home')
->get('/blog/category/[*:slug]-[i:id]', 'category/show', 'category')
->get('/blog/[*:slug]-[i:id]', 'post/show', 'post')
->match('/login','auth/login','login')
->match('/register','auth/register','register')
->post('/logout','auth/logout','logout')
->run();
我尝试创建.htaccess来重新编写规则,但没有找到好的配置。 文件index.php位于文件夹public中,文件夹public、src、视图位于项目的racine中

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /public/index.php [L]
这不管用

您能帮我配置.htaccess吗
提前感谢。

这里有一个很好的配置:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]