1

I have this document root /var/www/example and then inside this directory I have a file test.php, and also my other project so the structure of the project looks like this

/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]

I recently moved the project from a MAMP server running on localhost to a domain-driven server. When I try my

test.php

file it works and echo "It works" as intendended but when I try running my site it doesn´t .

error.log

 [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

My controller maps some of the sites by names to corresponding files like so

content of client_router all calls goes through index.php as htaccess and then to the router...

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"
);

I assume there could be something wrong either with my htaccess file, why i posted the contents, or there could be something wrong with my apache2.config file. But Im quite new on configuring apache so I wont try to post parts of it, as I probably would post the uncritical parts. Can somebody please help me. Thanks

4

1 回答 1

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

  2. 确保您的虚拟主机或服务器配置允许覆盖:

    AllowOverride FileInfo
    

    或者更好

    AllowOverride All        
    
  3. 不太可能,但请查看您的服务器/虚拟主机配置文件以查找名为AccessFilename. 默认情况下这通常是.htaccess,但如果它有所不同,那么您需要将其更改为.htaccess或将您的文件重命名为指令所说的任何内容。

于 2013-07-29T17:38:19.750 回答