Welcome to the Linux Foundation Forum!

Lab 8.2 - RewriteRule not working

CarloMartiniCarloMartini Posts: 16
edited January 2019 in LFS211 Class Forum

I followed step-by-step (I'm on a Fedora machine) the provided solution, and after enabling the log for Rewrite Rules, it DOES seem to work, even if I'm not sure about that last message (' to get passed through to next API URI-to-filename handler'):

[Sat Jan 12 14:13:16.457004 2019] [rewrite:trace2] [pid 957:tid 140718237189888] mod_rewrite.c(482): [client ::1:46332] ::1 - - [localhost/sid#55d059c0fd20][rid#7ffb78008c00/initial] init rewrite engine with requested uri /foo/bar
[Sat Jan 12 14:13:16.457064 2019] [rewrite:trace3] [pid 957:tid 140718237189888] mod_rewrite.c(482): [client ::1:46332] ::1 - - [localhost/sid#55d059c0fd20][rid#7ffb78008c00/initial] applying pattern '^/foo/(.*)' to uri '/foo/bar'
[Sat Jan 12 14:13:16.457085 2019] [rewrite:trace2] [pid 957:tid 140718237189888] mod_rewrite.c(482): [client ::1:46332] ::1 - - [localhost/sid#55d059c0fd20][rid#7ffb78008c00/initial] rewrite '/foo/bar' -> '/scripts/foo.cgi?bar'
[Sat Jan 12 14:13:16.457098 2019] [rewrite:trace3] [pid 957:tid 140718237189888] mod_rewrite.c(482): [client ::1:46332] ::1 - - [localhost/sid#55d059c0fd20][rid#7ffb78008c00/initial] split uri=/scripts/foo.cgi?bar -> uri=/scripts/foo.cgi, args=bar
[Sat Jan 12 14:13:16.457110 2019] [rewrite:trace2] [pid 957:tid 140718237189888] mod_rewrite.c(482): [client ::1:46332] ::1 - - [localhost/sid#55d059c0fd20][rid#7ffb78008c00/initial] forcing '/scripts/foo.cgi' to get passed through to next API URI-to-filename handler

Alas, when I visit http://localhost/foo/bar, the address is still the same (I also tried with wget/curl, so it doesn't seem a browser issue)

Comments

  • lee42xlee42x Posts: 158

    Hi Carlo ! Did the last step in exercise 8.1 work?
    It was :
    Restart Apache and test your new script. http://localhost/scripts/foo.cgi?bar
    If the exercise 8.1 functions then it is a rewrite issue if it did not then the foo.cgi script needs attention.

  • Yes, it did work. There was only a misconception on my part, sorry!

    The redirection was supposed to be "transparent" and that's exactly what's happening. I see the URL http://localhost/foo/bar instead of the URL http://localhost/scripts/foo.cgi?bar

    I missed the "transparent" part and for some reason I was convinced I should have been seeing the URL change to http://localhost/scripts/foo.cgi?bar.

    Sorry and thanks for your time.

  • AlexeyBYAlexeyBY Posts: 5

    Hi,
    I use CentOS
    Lab 8.1 is Ok. It works.
    Lab 8.2 is not working. --> The requested URL /scripts/foo/bar was not found on this server.

    I've done the virtualhost lab from the previous chapter. Probably the root of the reason is the file namevhost.conf.
    I don't understand how the file namevhost.conf must be corrected. How can I find _default_namevhost section ?

    Regards,
    Alexey

  • lee42xlee42x Posts: 158

    Hi Alexey,
    There are sample configuration files in the SOLUTIONS directories that should help. In the SOLUTIONS/s_07 directory is a file "namevhost.conf " with the "default " server stanza included.
    Let me know if this helps.
    Lee

Sign In or Register to comment.