Apache Rewrite module not working correctly

Clash Royale CLAN TAG#URR8PPP up vote
0
down vote
favorite
Keep on getting below error on Ubuntu 16.04 LTS.
404 Not Found
The requested URL /application/templates was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 00.0.0.00 Port 80
In the error.log showing:
No such file or directory in /var/www/html/aplication/api.php on line 228
Below are my current rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)/?$ $1.php [NC]
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)/?$ $1.html [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2&c=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2&c=$3
</IfModule>
Output for tail -f var/log/apache2/error.log
[Thu Jun 14 10:30:50.138694 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP Stack trace:
[Thu Jun 14 10:30:50.138704 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP 1. main() /var/www/html/TestCopy_Report1/index.php:0
Output for find:
sudo find / -iname api.php
find: âÂÂ/run/user/1000/gvfsâÂÂ: Permission denied
/var/www/html/application/api.php
/var/www/html/test1/api.php
/var/www/html/test2/api.php
/var/www/html/test3/api.php
/var/www/html/test4/api.php
/var/www/html/test5/api.php
apache2 mod-rewrite
 |Â
show 12 more comments
up vote
0
down vote
favorite
Keep on getting below error on Ubuntu 16.04 LTS.
404 Not Found
The requested URL /application/templates was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 00.0.0.00 Port 80
In the error.log showing:
No such file or directory in /var/www/html/aplication/api.php on line 228
Below are my current rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)/?$ $1.php [NC]
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)/?$ $1.html [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2&c=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2&c=$3
</IfModule>
Output for tail -f var/log/apache2/error.log
[Thu Jun 14 10:30:50.138694 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP Stack trace:
[Thu Jun 14 10:30:50.138704 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP 1. main() /var/www/html/TestCopy_Report1/index.php:0
Output for find:
sudo find / -iname api.php
find: âÂÂ/run/user/1000/gvfsâÂÂ: Permission denied
/var/www/html/application/api.php
/var/www/html/test1/api.php
/var/www/html/test2/api.php
/var/www/html/test3/api.php
/var/www/html/test4/api.php
/var/www/html/test5/api.php
apache2 mod-rewrite
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
1
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at/var/log/apache/error.logand such to determine what exactly is going on (i.e. what the server's looking for, etc.)
â Thomas Wardâ¦
Jun 12 at 16:52
1
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of thebutton in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.
â David Foerster
Jun 14 at 8:10
 |Â
show 12 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Keep on getting below error on Ubuntu 16.04 LTS.
404 Not Found
The requested URL /application/templates was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 00.0.0.00 Port 80
In the error.log showing:
No such file or directory in /var/www/html/aplication/api.php on line 228
Below are my current rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)/?$ $1.php [NC]
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)/?$ $1.html [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2&c=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2&c=$3
</IfModule>
Output for tail -f var/log/apache2/error.log
[Thu Jun 14 10:30:50.138694 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP Stack trace:
[Thu Jun 14 10:30:50.138704 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP 1. main() /var/www/html/TestCopy_Report1/index.php:0
Output for find:
sudo find / -iname api.php
find: âÂÂ/run/user/1000/gvfsâÂÂ: Permission denied
/var/www/html/application/api.php
/var/www/html/test1/api.php
/var/www/html/test2/api.php
/var/www/html/test3/api.php
/var/www/html/test4/api.php
/var/www/html/test5/api.php
apache2 mod-rewrite
Keep on getting below error on Ubuntu 16.04 LTS.
404 Not Found
The requested URL /application/templates was not found on this server.
Apache/2.4.18 (Ubuntu) Server at 00.0.0.00 Port 80
In the error.log showing:
No such file or directory in /var/www/html/aplication/api.php on line 228
Below are my current rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.php -f
RewriteRule ^(.*)$ $1.php
#RewriteRule ^([a-z]+)/?$ $1.php [NC]
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME.html -f
RewriteRule ^(.*)$ $1.html
#RewriteRule ^([a-z]+)/?$ $1.html [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?a=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?a=$1&b=$2&c=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?a=$1&b=$2&c=$3
</IfModule>
Output for tail -f var/log/apache2/error.log
[Thu Jun 14 10:30:50.138694 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP Stack trace:
[Thu Jun 14 10:30:50.138704 2018] [:error] [pid 7150] [client 172.29.9.57:38776] PHP 1. main() /var/www/html/TestCopy_Report1/index.php:0
Output for find:
sudo find / -iname api.php
find: âÂÂ/run/user/1000/gvfsâÂÂ: Permission denied
/var/www/html/application/api.php
/var/www/html/test1/api.php
/var/www/html/test2/api.php
/var/www/html/test3/api.php
/var/www/html/test4/api.php
/var/www/html/test5/api.php
apache2 mod-rewrite
edited Jun 15 at 7:42
asked Jun 12 at 5:56
Anand
12
12
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
1
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at/var/log/apache/error.logand such to determine what exactly is going on (i.e. what the server's looking for, etc.)
â Thomas Wardâ¦
Jun 12 at 16:52
1
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of thebutton in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.
â David Foerster
Jun 14 at 8:10
 |Â
show 12 more comments
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
1
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at/var/log/apache/error.logand such to determine what exactly is going on (i.e. what the server's looking for, etc.)
â Thomas Wardâ¦
Jun 12 at 16:52
1
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of thebutton in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.
â David Foerster
Jun 14 at 8:10
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
1
1
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at
/var/log/apache/error.log and such to determine what exactly is going on (i.e. what the server's looking for, etc.)â Thomas Wardâ¦
Jun 12 at 16:52
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at
/var/log/apache/error.log and such to determine what exactly is going on (i.e. what the server's looking for, etc.)â Thomas Wardâ¦
Jun 12 at 16:52
1
1
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of the
button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.â David Foerster
Jun 14 at 8:10
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of the
button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.â David Foerster
Jun 14 at 8:10
 |Â
show 12 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Finally found a solution:
sudo nano /etc/apache2/sites-available/000-default.conf
Added below lines to `/etc/apache2/sites-available/000-default.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I was required to setup Apache Virtual Hosts.
Thanks for everyone.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Finally found a solution:
sudo nano /etc/apache2/sites-available/000-default.conf
Added below lines to `/etc/apache2/sites-available/000-default.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I was required to setup Apache Virtual Hosts.
Thanks for everyone.
add a comment |Â
up vote
0
down vote
accepted
Finally found a solution:
sudo nano /etc/apache2/sites-available/000-default.conf
Added below lines to `/etc/apache2/sites-available/000-default.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I was required to setup Apache Virtual Hosts.
Thanks for everyone.
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Finally found a solution:
sudo nano /etc/apache2/sites-available/000-default.conf
Added below lines to `/etc/apache2/sites-available/000-default.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I was required to setup Apache Virtual Hosts.
Thanks for everyone.
Finally found a solution:
sudo nano /etc/apache2/sites-available/000-default.conf
Added below lines to `/etc/apache2/sites-available/000-default.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I was required to setup Apache Virtual Hosts.
Thanks for everyone.
answered Jun 15 at 11:23
Anand
12
12
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1045802%2fapache-rewrite-module-not-working-correctly%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This depends on the application you are trying to run. Which one is it?
â Melebius
Jun 12 at 7:49
PHP web application using PHP5.6.34,mysql5.7.22,apache2.4 and mustache template
â Anand
Jun 12 at 8:05
I am sorry, your comment did not provide any information about whether (and how) your application requires the rewrite module.
â Melebius
Jun 12 at 8:09
1
rewrite module is Apache, not PHP. You also need to configure the thing properly to do the rewrites and restart Apache afterwards. If you still get a 404, then you need to start looking at
/var/log/apache/error.logand such to determine what exactly is going on (i.e. what the server's looking for, etc.)â Thomas Wardâ¦
Jun 12 at 16:52
1
Welcome to Ask Ubuntu! Could you please edit your post when you want to add information? Especially file or program output listings (with the help of the
button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall itâÂÂs best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks.â David Foerster
Jun 14 at 8:10