Reputation: 675
We have a ubuntu machine on ec2 as a server, and the default /var/www/html
has a sym link to /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
public_html/app/
which is the home (base) for 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:
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.)
Upvotes: 1
Views: 844
Reputation: 675
There were two problems:
As @the-agony has mentioned above, RewriteBase was likely duplicating the rule, so switched to this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /website/public_html/app/index.php/$1 [L]
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.
Upvotes: 0
Reputation: 200
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
Upvotes: 2