2017-04-02 58 views
-1

我有一個Ubuntu服務器。我在那裏安裝了Apache,添加了我的文件,之後我沒有發現任何錯誤,只是無法連接到該地址。 (對於我的文件,我也必須啓用.htaccess)。我將在這裏添加.htaccess,但即使我刪除了.htaccess文件,該錯誤仍然存​​在。在ubuntu apache服務器上安裝我的文件後,它停止工作

RewriteEngine on 
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA] 
RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA] 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

order allow,deny 
allow from all 

我也有一個vendor/autoload.php有我不知道如果我要安裝的東西爲使其工作100%。

Apache的錯誤日誌

[Mon Apr 03 18:25:51.487006 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] strip per-dir prefix: /var/www/ -> 
[Mon Apr 03 18:25:51.487042 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] applying pattern '^(\\w+)$' to uri '' 
[Mon Apr 03 18:25:51.487047 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] strip per-dir prefix: /var/www/ -> 
[Mon Apr 03 18:25:51.487050 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] applying pattern '^(\\w+)+\\/$' to uri '' 
[Mon Apr 03 18:25:51.487053 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] strip per-dir prefix: /var/www/ -> 
[Mon Apr 03 18:25:51.487055 2017] [rewrite:trace3] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] applying pattern '^' to uri '' 
[Mon Apr 03 18:25:51.487061 2017] [rewrite:trace4] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] RewriteCond: input='EXAMPLE.com' pattern='!^$' => matched 
[Mon Apr 03 18:25:51.487065 2017] [rewrite:trace4] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] RewriteCond: input='EXAMPLE.com' pattern='!^www\\.' [NC] => matched 
[Mon Apr 03 18:25:51.487069 2017] [rewrite:trace4] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] RewriteCond: input='offs' pattern='^on(s)|' => matched 
[Mon Apr 03 18:25:51.487077 2017] [rewrite:trace2] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] rewrite '' -> 'http://www.EXAMPLE.com/' 
[Mon Apr 03 18:25:51.487081 2017] [rewrite:trace2] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] explicitly forcing redirect with http://www.EXAMPLE.com/ 
[Mon Apr 03 18:25:51.487084 2017] [rewrite:trace1] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] escaping http://www.EXAMPLE.com/ for redirect 
[Mon Apr 03 18:25:51.487090 2017] [rewrite:trace1] [pid 53934] mod_rewrite.c(468): [client 127.0.0.1:63842] 127.0.0.1 - - [EXAMPLE.com/sid#7fc536e48158][rid#7fc536d8e0a0/initial] [perdir /var/www/] redirect to http://www.EXAMPLE.com/ [REDIRECT/301] 
+0

包含您收到的錯誤消息很有幫助。 –

+0

你看過阿帕奇的錯誤日誌嗎?它應該是'/ var/log/apache2/error.log' –

+0

它沒有得到任何錯誤信息。只有我得到的是'這個網站無法到達'。 –

回答

0

首先我建議改變你的.htaccess文件:

RewriteEngine on 

RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule .? https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{HTTPS} off 
RewriteRule .? https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

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

這應該做你試圖實現與你的配置相同,但在正確的順序和乾淨的語法。

也失去了

order allow,deny 
allow from all 

,因爲它不會在這裏提供任何好處。也許你的地方定義的DocumentRoot的,你必須把這個「的順序allow'部分進入目錄的指令爲你的DocumentRoot,例如:

DocumentRoot "/srv/www/htdocs" 

<Directory "/srv/www/htdocs"> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory> 

如果有錯誤或左非功能,增加你的'LogLevel'在error.log中發出警告甚至是信息,重新啓動並檢查error.log

+0

嘿,我認爲問題是我試圖通過我的VPS IP連接到我的網站,因爲我沒有一個域,我認爲這是由.htaccess文件引起的。 –

+0

如果還有錯誤或無功能,請在error.log中增加'LogLevel'以警告或甚至重新啓動並檢查error.log –

+0

如何增加LogLevel? –

相關問題