Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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 404移动目录位置时找不到url(htaccess)_Php_Apache_.htaccess - Fatal编程技术网

Php 404移动目录位置时找不到url(htaccess)

Php 404移动目录位置时找不到url(htaccess),php,apache,.htaccess,Php,Apache,.htaccess,我有这个文档根/var/www/example,然后在这个目录中有一个文件test.php,还有我的另一个项目,因此项目的结构如下所示 /var/www/example ├── .htaccess (Obs) ├── classes  ├── config ├── controllers ├── public │   ├── admin │   │   └── index.php │   ├── css │   ├── index.php │   └── js ├── test.php (O

我有这个文档根
/var/www/example
,然后在这个目录中有一个文件
test.php
,还有我的另一个项目,因此项目的结构如下所示

/var/www/example

├── .htaccess (Obs)
├── classes  
├── config
├── controllers
├── public
│   ├── admin
│   │   └── index.php 
│   ├── css
│   ├── index.php
│   └── js
├── test.php (Obs! not managed by .htaccess)
└── views
.htaccess

Options +FollowSymLinks
AddDefaultCharset UTF-8 
RewriteEngine On

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

RewriteRule ^admin[/]?$ /example/admin/login [redirect]
RewriteRule ^admin/([a-zA-Z]+)/?([a-zA-Z0-9/]*)$ public/admin/index.php?page=$1&query=$2 [L]
RewriteRule ^([a-zA-Z]+)/?([a-zA-Z0-9/]*)$ public/index.php?page=$1&query=$2 [L]
我最近将项目从运行在localhost上的MAMP服务器移动到了域驱动服务器。当我尝试我的

test.php

文件,它可以正常工作,
echo“它可以正常工作”
,但当我尝试运行我的站点时,它却不能

错误。日志

 [Mon Jul 29 18:02:52 2013] [error] [client 83.248.93.217] script '/var/www/example/index.php' not found or unable to stat
 [Mon Jul 29 18:02:52 2013] [error] [client 83.248.93.217] File does not exist:     /var/www/favicon.ico
 [Mon Jul 29 18:03:02 2013] [error] [client 83.248.93.217] File does not exist: /var/www/example/bordsoversikt
 [Mon Jul 29 18:03:02 2013] [error] [client 83.248.93.217] File does not exist: /var/www/favicon.ico
我的控制器通过名称将一些站点映射到相应的文件,如下所示

客户端路由器的内容所有调用都作为
htaccess
通过index.php,然后到达路由器

public function initialize_routes() {
$this->routes = array(
    "bordsoversikt" => "page_table_overview",
    "bordsreservation" => "page_table_reservation",
    "reservationsprocess" => "script_reserve_form",
    "registrering" => "page_registration",
    "registreringsprocess" => "script_register_form",
    "lyckadregistrering" => "page_successfull_signup",
    "login" => "page_login",
    "logout" => "script_logout",
    "profil" => "page_home", 
    "klientlogin" => "script_login",
    "profil" => "page_profile",
    "sparaprofil" => "script_edit_profile_changes"
);
我假设我的htaccess文件可能有问题,为什么我发布了内容,或者我的
apache2.config
文件可能有问题。但是我对配置apache非常陌生,所以我不会尝试发布部分内容,因为我可能会发布不重要的部分。谁能帮帮我吗。谢谢

  • 确保您的htaccess文件可由apache读取(例如,在linux上,
    chmod 644/var/www/example/.htaccess

  • 确保vhost或服务器配置允许覆盖:

    AllowOverride FileInfo
    
    或者更好

    AllowOverride All        
    
  • 不太可能,但请在服务器/vhost配置文件中查找名为的命令。默认情况下,这通常是.htaccess,但如果是不同的内容,则需要将其更改为.htaccess,或者将文件重命名为指令所述的任何文件

  • 确保您的htaccess文件可由apache读取(例如,在linux上,
    chmod 644/var/www/example/.htaccess

  • 确保vhost或服务器配置允许覆盖:

    AllowOverride FileInfo
    
    或者更好

    AllowOverride All        
    
  • 不太可能,但请在服务器/vhost配置文件中查找名为的命令。默认情况下,这通常是.htaccess,但如果是不同的内容,则需要将其更改为.htaccess,或者将文件重命名为指令所述的任何文件


  • 请解释失败的原因!检查apache
    error.log
    文件!好的,编辑了问题..你确定.htaccess被apache使用了吗?把一些无效的东西放到.htaccess,随机字符序列,随便什么.是的,它没有被读取。如果未设置AllowOverride,apache甚至懒得阅读。htaccess请解释失败的原因!检查apache
    error.log
    文件!好的,编辑了问题..你确定.htaccess被apache使用了吗?把一些无效的东西放到.htaccess,随机字符序列,随便什么.是的,它没有被读取。如果未设置AllowOverride,apache甚至懒得阅读!这确实是问题所在。我需要让我的最爱超越一切。但是那里有很多虚拟主机。如果有人有同样的问题,我建议你找到一个中继到你的站点我的问题,例如在/var/apache2/sites enabled/000 defaultYes谢谢!这确实是问题所在。我需要让我的最爱超越一切。但是那里有很多虚拟主机。如果有人有同样的问题,我建议您找到一个中继到您的站点的问题,例如在/var/apache2/sites enabled/000 default中