简体   繁体   English

apache2上的符号链接和htaccess

[英]symbolic links and htaccess on apache2

We have a ubuntu machine on ec2 as a server, and the default /var/www/html has a sym link to /home/ubuntu 我们在ec2上有一台ubuntu机器作为服务器,默认的/var/www/html有一个符号链接到/home/ubuntu

ubuntu@ip-172-XX-XX-XXX:/var/www/html$ ls -al
total 20
drwxrwxrwx 2 root root  4096 Sep 10 02:19 .
drwxr-xr-x 3 root root  4096 Sep 10 02:17 ..
-rw-r--r-- 1 root root 11321 Sep 10 02:17 index.html
lrwxrwxrwx 1 root root    20 Sep 10 02:19 website -> /home/ubuntu/website

The directory /home/ubuntu/website contains 目录/home/ubuntu/website包含

public_html/app/

which is the home (base) for CodeIgniter. 这是CodeIgniter的主页(基础)。 When I access the website as 当我以以下方式访问网站时

http://ec2-34-XXX-XX-XXX.compute-1.amazonaws.com/website/public_html/app/index.php/login

I can see the page loaded correctly. 我可以看到页面已正确加载。 But when I access it as 但是当我以

http://ec2-34-XXX-XX-XXX.compute-1.amazonaws.com/website/public_html/app/login

I can't - It shows 我不能-它显示

Not Found

The requested URL /website/public_html/app/login was not found on this server.

The .htaccess file is as follows: .htaccess文件如下:

RewriteEngine on
RewriteBase /website/public_html/app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /website/public_html/app/index.php/$1 [L]

What am I missing here ? 我在这里想念什么? (Mod Rewrite is enabled.) (启用了“ Mod Rewrite”。)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /website/public_html/app/index.php/$1 [L]

I think that RewriteBase is the problem as it duplicates the rule in RewriteRule 我认为RewriteBase是一个问题,因为它重复了RewriteRule中的规则

There were two problems: 有两个问题:

  1. As @the-agony has mentioned above, RewriteBase was likely duplicating the rule, so switched to this: 就像@ the-agony上面提到的那样,RewriteBase可能复制了规则,所以切换到此:

    RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /website/public_html/app/index.php/$1 [L]

  2. Moreover checking the log by 而且通过检查日志

    sudo tail /var/log/apache2/error.log

showed: 结果显示:

    [Wed Oct 11 19:41:36.396178 2017] [core:alert] [pid 30110] [client 130.245.192.0:27286] /var/www/html/website/public_html/.htaccess: Expected </IfModule> before end of configuration
    [Wed Oct 11 19:44:11.269472 2017] [core:alert] [pid 30106] [client 130.245.192.0:13926] /var/www/html/website/public_html/.htaccess: Expected </IfModule> before end of configuration
    [Wed Oct 11 19:44:14.046920 2017] [core:alert] [pid 30108] [client 130.245.192.0:22481] /var/www/html/website/public_html/.htaccess: Expected </IfModule> before end of configuration
    [Wed Oct 11 19:44:15.465143 2017] [core:alert] [pid 30107] [client 130.245.192.0:19889] /var/www/html/website/public_html/.htaccess: Expected </IfModule> before end of configuration

The problem was with the .htaccess file in /public_html directory as well. 问题也出在/ public_html目录中的.htaccess文件中。

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

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