Apache Rewrite module not working correctly

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite
1












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






share|improve this question





















  • 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.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




    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














up vote
0
down vote

favorite
1












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






share|improve this question





















  • 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.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




    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












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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






share|improve this question













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








share|improve this question












share|improve this question




share|improve this question








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.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




    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
















  • 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.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




    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















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










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.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer













        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.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 15 at 11:23









        Anand

        12




        12






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error

            How do I move numbers in filenames, in a batch renaming operation?