【问题标题】:eBot CS:GO Apache 2.4.10 Mod Rewrite does not workeBot CS:GO Apache 2.4.10 Mod Rewrite 不起作用
【发布时间】:2016-04-01 03:53:33
【问题描述】:

我已经成功安装了以下网页界面:https://github.com/deStrO/eBot-CSGO-Web

我已经配置了 Apache vHost,如下所示:

<VirtualHost *:80>
      ServerAdmin <email>
      DocumentRoot /var/www/ebot-web/web

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/var/www/ebot-web/ 看起来像这样:

# ls -lha /var/www/ebot-web/
total 56K
drwxr-xr-x 10 www-data www-data 4.0K Dec 26 16:27 .
drwxr-xr-x  4 root     root     4.0K Dec 26 16:22 ..
drwxr-xr-x  4 www-data www-data 4.0K Apr  3  2015 apps
drwxr-xr-x  4 www-data www-data 4.0K Dec 26 19:30 cache
drwxr-xr-x  3 www-data www-data 4.0K Dec 26 18:22 config
drwxr-xr-x  4 www-data www-data 4.0K Dec 26 19:30 data
-rw-r--r--  1 www-data www-data   41 Apr  3  2015 .gitignore
drwxr-xr-x  7 www-data www-data 4.0K Apr  3  2015 lib
drwxr-xr-x  6 www-data www-data 4.0K Apr  3  2015 plugins
-rw-r--r--  1 www-data www-data 1.1K Apr  3  2015 README.md
-rw-r--r--  1 www-data www-data  446 Apr  3  2015 symfony
drwxr-xr-x  4 www-data www-data 4.0K Apr  3  2015 test
-rw-r--r--  1 www-data www-data 2.1K Apr  3  2015 TODO
drwxr-xr-x  6 www-data www-data 4.0K Dec 26 19:29 web

/var/www/ebot-web/web/ 看起来像这样:

# ls -lha /var/www/ebot-web/web/
total 48K
drwxr-xr-x  6 www-data www-data 4.0K Dec 26 19:29 .
drwxr-xr-x 10 www-data www-data 4.0K Dec 26 16:27 ..
-rw-r--r--  1 www-data www-data  235 Apr  3  2015 admin.php
drwxr-xr-x  3 www-data www-data 4.0K Apr  3  2015 css
-rw-r--r--  1 www-data www-data 4.7K Apr  3  2015 favicon.png
-rw-r--r--  1 www-data www-data  595 Dec 26 19:24 .htaccess
drwxr-xr-x  6 www-data www-data 4.0K Apr  3  2015 images
drwxr-xr-x  2 www-data www-data 4.0K Apr  3  2015 img
-rw-r--r--  1 www-data www-data  236 Apr  3  2015 index.php
drwxr-xr-x  3 www-data www-data 4.0K Apr  3  2015 js
-rw-r--r--  1 www-data www-data   26 Dec 26 19:29 robots.txt

我可以通过打开 http://hostname/ 访问 Web 界面,并且管理后端工作正常。但是在前端我遇到了问题,所有 URL 都不起作用。我总是从我的浏览器收到以下错误消息:

404 Not Found - The requested URL /credits was not found on this server.

所有网址都像这样链接:http://hostname/credits

嗯...如果我使用http://hostname/index.php/credits 手动打开该站点,则可以访问该站点。

我认为 .htaccess 文件存在问题,但我不确定,也没有所需的技能。

/var/www/ebot-web # find . -name .htaccess
./web/.htaccess
./lib/vendor/symfony/lib/task/generator/skeleton/project/web/.htaccess

这是 /var/www/ebot-web/web/.htaccess 文件的内容:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
 </IfModule>

我已按照建议取消了上述行的注释,但它并没有改变任何东西。如果我启用警告日志级别,网络服务器日志也是空的。

问题是,URL 中缺少“index.php”。但是重写规则应该插入这个,还是不插入?

重写模块已启用:

# a2enmod rewrite
Module rewrite already enabled

有人可以帮帮我吗?

【问题讨论】:

    标签: php apache .htaccess mod-rewrite


    【解决方案1】:

    该死的。我必须通过 vHost 配置中的 .htaccess 来允许此类更改。我已经在 vHost VirtualHost 配置中添加了这个:

        <VirtualHost *:80>
            ...
            <Directory /var/www/ebot-web/web>
                    AllowOverride All
            </Directory>
            ...
        </VirtualHost>
    

    现在运行良好! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-10
      • 1970-01-01
      • 2012-07-21
      • 2011-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多