繁体   English   中英

重写无法与apache2和laravel一起使用的网址

[英]Rewrite urls not working with apache2 and laravel

今天,我在服务器上启动了一个新项目。 以我的观点,我想我已经正确配置了所有东西。 但是,我的.htaccess似乎无法正常工作,或者已被忽略。 我不知道为什么它不起作用。 问题在于重写网址将显示404。

基于Laravel 5.0或更高版本的项目我将尝试Larasocial。 Larasocial是一个基于Laravel 5的社交社区。

我检查了我的Vhosts和Htaccess文件,但找不到正确的问题。 还尝试使用service apache2 restart重新启动apache,并查看是否为我的apache启用了重写模块。 我想一切都应该没事。

在此先感谢您的帮助!

现在,这是我的虚拟主机和Htaccess。

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName integration.julian.droeger.rene-backhaus.de

    ServerAdmin contact@rene-backhaus.de
    DocumentRoot /var/www/html/robot/customers/julian.droeger/integration/public

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog /home/robot/logs/customers/error.log
    CustomLog /home/robot/logs/customers/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

        # Das folgende erzwingt SSL
    #RewriteEngine On
    #RewriteCond %{HTTPS} off
    #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
         <Directory /var/www/robot/customers/julian.droeger/integration/public>
          #Options Indexes FollowSymLinks 
          AllowOverride All
      #Require all granted
        </Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =rene-backhaus.de
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

SSL协议

<IfModule mod_ssl.c>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName integration.julian.droeger.rene-backhaus.de

    ServerAdmin contact@rene-backhaus.de
    DocumentRoot /var/www/html/robot/customers/julian.droeger/integration/public/

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog /home/robot/logs/customers/error.log
    CustomLog /home/robot/logs/customers/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

        # Das folgende erzwingt SSL
    #RewriteEngine On
    #RewriteCond %{HTTPS} off
    #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
         <Directory /var/www/robot/customers/julian.droeger/integrationi/public>
          #Options Indexes FollowSymLinks
           AllowOverride All
           #Require all granted
    </Directory>
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
# RewriteCond %{SERVER_NAME} =rene-backhaus.de
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/rene-backhaus.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/rene-backhaus.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

高温通行

</IfModule>
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

编辑

Apache错误日志:

[Sun Sep 17 12:42:35.463054 2017] [core:notice] [pid 6843] AH00094: Command line: '/usr/sbin/apache2'
[Sun Sep 17 12:42:42.107113 2017] [mpm_prefork:notice] [pid 6843] AH00171: Graceful restart requested, doing restart
[Sun Sep 17 12:42:42.153704 2017] [mpm_prefork:notice] [pid 6843] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1t configured -- resuming normal operations
[Sun Sep 17 12:42:42.153724 2017] [core:notice] [pid 6843] AH00094: Command line: '/usr/sbin/apache2'
[Sun Sep 17 12:42:44.121750 2017] [mpm_prefork:notice] [pid 6843] AH00171: Graceful restart requested, doing restart
[Sun Sep 17 12:42:44.163280 2017] [mpm_prefork:notice] [pid 6843] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1t configured -- resuming normal operations
[Sun Sep 17 12:42:44.163295 2017] [core:notice] [pid 6843] AH00094: Command line: '/usr/sbin/apache2'
[Sun Sep 17 12:42:46.255223 2017] [mpm_prefork:notice] [pid 6843] AH00171: Graceful restart requested, doing restart
[Sun Sep 17 12:42:46.301081 2017] [mpm_prefork:notice] [pid 6843] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1t configured -- resuming normal operations
[Sun Sep 17 12:42:46.301109 2017] [core:notice] [pid 6843] AH00094: Command line: '/usr/sbin/apache2'

虚拟主机访问日志:

79.214.162.134 - - [17/Sep/2017:12:44:02 +0200] "GET /fonts/glyphicons-halflings-regular.woff2 HTTP/1.1" 200 18377 "https://integration.thomas.walczak.rene-backhaus.de/css/libs.css" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:12:44:18 +0200] "GET /feeds HTTP/1.1" 404 725 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:12:44:18 +0200] "GET /favicon.ico HTTP/1.1" 404 593 "https://integration.thomas.walczak.rene-backhaus.de/feeds" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:13:58:26 +0200] "GET / HTTP/1.1" 200 6771 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:13:59:43 +0200] "GET / HTTP/1.1" 200 3664 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:13:59:51 +0200] "GET /feeds HTTP/1.1" 404 725 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:14:00:34 +0200] "GET /feeds HTTP/1.1" 404 725 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:14:00:35 +0200] "GET /feeds HTTP/1.1" 404 587 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:14:01:04 +0200] "GET /feeds HTTP/1.1" 404 725 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"
79.214.162.134 - - [17/Sep/2017:14:01:05 +0200] "GET /feeds HTTP/1.1" 404 587 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36"

虚拟主机错误日志:

[Sat Sep 16 22:57:22.509547 2017] [:error] [pid 30198] [client 217.238.62.18:64841] script '/var/www/html/robot/customers/julian.droeger/integration/status.php' not found or unable to stat
[Sat Sep 16 22:57:23.156553 2017] [:error] [pid 30198] [client 217.238.62.18:64841] script '/var/www/html/robot/customers/julian.droeger/integration/remote.php' not found or unable to stat
[Sat Sep 16 22:57:54.927797 2017] [:error] [pid 30191] [client 217.238.62.18:64850] script '/var/www/html/robot/customers/julian.droeger/integration/status.php' not found or unable to stat
[Sat Sep 16 22:57:55.068064 2017] [:error] [pid 30191] [client 217.238.62.18:64850] script '/var/www/html/robot/customers/julian.droeger/integration/remote.php' not found or unable to stat
[Sat Sep 16 22:58:26.504328 2017] [:error] [pid 30190] [client 217.238.62.18:64852] script '/var/www/html/robot/customers/julian.droeger/integration/status.php' not found or unable to stat
[Sat Sep 16 22:58:26.614808 2017] [:error] [pid 30190] [client 217.238.62.18:64852] script '/var/www/html/robot/customers/julian.droeger/integration/remote.php' not found or unable to stat
[Sat Sep 16 22:58:58.510322 2017] [:error] [pid 30197] [client 217.238.62.18:64853] script '/var/www/html/robot/customers/julian.droeger/integration/status.php' not found or unable to stat
[Sat Sep 16 22:58:58.620842 2017] [:error] [pid 30197] [client 217.238.62.18:64853] script '/var/www/html/robot/customers/julian.droeger/integration/remote.php' not found or unable to stat
[Sat Sep 16 22:59:30.507615 2017] [:error] [pid 30191] [client 217.238.62.18:64863] script '/var/www/html/robot/customers/julian.droeger/integration/status.php' not found or unable to stat
[Sat Sep 16 22:59:30.639602 2017] [:error] [pid 30191] [client 217.238.62.18:64863] script '/var/www/html/robot/customers/julian.droeger/integration/remote.php' not found or unable to stat

莱塞恩学会了我猜...

本文复习了我的apache.conf 我在那看到的是什么? 没有为/var/www启用htaccess! 现在解决方案非常简单,我不得不将AllowOverride None更改为AllowOverride All 它解决了这个问题!

但是最后我已经有一个问题。 在本文开始之前,我认为Vhost配置将是重要的配置。 为了使AllowOverride在Vhost文件中的All上,apache将采用此配置。 为什么apache2需要全局的AllowOverride All配置? 有人可以解释吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM