apache - Seems to be .htaccess mod_rewrite issue on Laravel site - proper setup? -


i have laravel 5.2 site. .htaccess file under public folder. have following .htaccess file:

<ifmodule mod_negotiation.c>     options -multiviews </ifmodule>  rewriteengine on  rewriterule ^category/(.*)/(.*) guitar-lessons/$2/$1 [nc,r=301]  # redirect trailing slashes if not folder... rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301]  # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l]  # handle authorization header rewritecond %{http:authorization} . rewriterule .* - [e=http_authorization:%{http:authorization}] 

this how previous developers set up. site owner , not web developer, familiar web development, server configuration, etc.

i changed url structure on site , added 1 line .htaccess file:

rewriterule ^category/(.*)/(.*) guitar-lessons/$2/$1 [nc,r=301] 

so link of form site.com/category/1/scales should rewritten site.com/guitar-lessons/scales/1

i added rewrite logging, , when testing on localhost, see in error log:

add per-dir prefix: guitar-lessons/scales/1 -> /library/webserver/documents/mysite/public/guitar-lessons/scales/1     [wed jul 26 00:32:47.469564 2017] [rewrite:trace2] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] explicitly forcing redirect http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1     [wed jul 26 00:32:47.469568 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] add path info postfix: http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1 -> http://local$     [wed jul 26 00:32:47.469572 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] applying pattern '^(.*)/$' uri 'http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1/1/s$     [wed jul 26 00:32:47.469578 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] add path info postfix: http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1 -> http://local$     [wed jul 26 00:32:47.469582 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] applying pattern '^' uri 'http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1/1/scales'     [wed jul 26 00:32:47.469594 2017] [rewrite:trace2] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] rewrite 'http://localhost/library/webserver/documents/mysite/public/guitar-lessons/scales/1/1/scales' -> 'index.php'     [wed jul 26 00:32:47.469598 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] add per-dir prefix: index.php -> /library/webserver/documents/mysite/public/index.php     [wed jul 26 00:32:47.469605 2017] [rewrite:trace2] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] strip document_root prefix: /library/webserver/documents/mysite/public/index.php -> /index.php     [wed jul 26 00:32:47.469608 2017] [rewrite:trace1] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89f00aaa0/initial] [perdir /library/webserver/documents/mysite/public/] internal redirect /index.php [internal redirect]     [wed jul 26 00:32:47.472007 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] strip per-dir prefix: /library/webserver/documents/mysite/public/index.php -> index.php     [wed jul 26 00:32:47.472020 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] applying pattern '^category/(.*)/(.*)' uri 'index.php'     [wed jul 26 00:32:47.472033 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] strip per-dir prefix: /library/webserver/documents/mysite/public/index.php -> index.php     [wed jul 26 00:32:47.472038 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] applying pattern '^(.*)/$' uri 'index.php'     [wed jul 26 00:32:47.472044 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] strip per-dir prefix: /library/webserver/documents/mysite/public/index.php -> index.php     [wed jul 26 00:32:47.472048 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] applying pattern '^' uri 'index.php'     [wed jul 26 00:32:47.472060 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] strip per-dir prefix: /library/webserver/documents/mysite/public/index.php -> index.php     [wed jul 26 00:32:47.472064 2017] [rewrite:trace3] [pid 10084] mod_rewrite.c(477): [client ::1:58524] ::1 - - [localhost/sid#7fd89e81f6f8][rid#7fd89e87fbf0/initial/redir#1] [perdir /library/webserver/documents/mysite/public/] applying pattern '.*' uri 'index.php' 

as can see, odd going on. @ first well, note this:

add path info postfix: http://localhost/library/webserver/documents/guitar-dreams/public/guitar-lessons/scales/1 -> http://localhost/library/webserver/documents/guitar-dreams/public/guitar-lessons/scales/1/1/scales 

this adding path info messing up. idea how correct in simplest way possible? want keep .htaccess in public folder , not make complicated...

thanks!


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -