apache - My mod_rewrite rules do not resolve PHP variables -
i have interesting situation. i've configured basic lamp server , external company providing code. works except php rewrites specifically.
i've configured rewrites , can basic rewrites hello.html -> redir.html. i've confirmed turning loglevel trace6 , see rewrite being active.
the trouble comes php variables. seems not resolve them.
i have following simplified .htaccess file other rules removed testing
<ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^news/(.*)/(.*)/(.*)/$ news.php?department=$1&newsid=$2&newstitle=$3 [l] rewriterule ^$ index.php?page=home [l] </ifmodule>
now if enter url http://webserver/news/it/153/newsstory
i expect redirected
http://webserver/news.php?department=it&newsid=153&newstitle=newsstory
however, happens second rule catches it.
this tricky me, i'm providing server infrastructure , not writing code (externally supplied). our code supplier says works side , we've seen working demos, i've been sort of troubleshooting 'we missing packages or configs somehow' angle.
as far can tell online, if mod_rewrite working, should... work.
a log dump of incorrect redir
[perdir /var/www/itnews/] add path info postfix: /var/www/itnews/news.php -> /var/www/itnews/news.php/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/news.php/it/153/newsstory -> news.php/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'news.php/it/153/newsstory' [perdir /var/www/itnews/] add path info postfix: /var/www/itnews/news.php -> /var/www/itnews/news.php/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/news.php/it/153/newsstory -> news.php/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'news.php/it/153/newsstory' [perdir /var/www/itnews/] pass through /var/www/itnews/news.php [perdir /var/www/itnews/] add path info postfix: /var/www/itnews/news.php -> /var/www/itnews/news.php/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/news.php/it/153/newsstory -> news.php/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'news.php/it/153/newsstory' [perdir /var/www/itnews/] add path info postfix: /var/www/itnews/news.php -> /var/www/itnews/news.php/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/news.php/it/153/newsstory -> news.php/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'news.php/it/153/newsstory' [perdir /var/www/itnews/] pass through /var/www/itnews/news.php [perdir /var/www/itnews/] add path info postfix: /var/www/itnews/it -> /var/www/itnews/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/it/153/newsstory -> it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'it/153/newsstory' [perdir /var/www/itnews/] add path info postfix: /var/www/itnews/it -> /var/www/itnews/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/it/153/newsstory -> it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'it/153/newsstory' [perdir /var/www/itnews/] pass through /var/www/itnews/it [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/images/logo.jpg -> images/logo.jpg, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'images/logo.jpg', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/images/logo.jpg -> images/logo.jpg, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'images/logo.jpg', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/images/logo.jpg, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/bootstrap.min.css -> css/bootstrap.min.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'css/bootstrap.min.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/bootstrap.min.css -> css/bootstrap.min.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'css/bootstrap.min.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/css/bootstrap.min.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/style.css -> css/style.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'css/style.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/style.css -> css/style.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'css/style.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/css/style.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/js/bootstrap.min.js -> js/bootstrap.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'js/bootstrap.min.js', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/js/bootstrap.min.js -> js/bootstrap.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'js/bootstrap.min.js', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/js/bootstrap.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/prettycheckable.css -> css/prettycheckable.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'css/prettycheckable.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/css/prettycheckable.css -> css/prettycheckable.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'css/prettycheckable.css', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/css/prettycheckable.css, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/js/jquery-1.11.0.min.js -> js/jquery-1.11.0.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'js/jquery-1.11.0.min.js', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/js/jquery-1.11.0.min.js -> js/jquery-1.11.0.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'js/jquery-1.11.0.min.js', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/js/jquery-1.11.0.min.js, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/plugins/timthumb.php -> plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'plugins/timthumb.php', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/plugins/timthumb.php, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/fonts/ocean_sans_std_book-webfont.woff -> fonts/ocean_sans_std_book-webfont.woff, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^news/(.*)/(.*)/(.*)$' uri 'fonts/ocean_sans_std_book-webfont.woff', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/fonts/ocean_sans_std_book-webfont.woff -> fonts/ocean_sans_std_book-webfont.woff, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] applying pattern '^$' uri 'fonts/ocean_sans_std_book-webfont.woff', referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] pass through /var/www/itnews/fonts/ocean_sans_std_book-webfont.woff, referer: http://webserver/news/it/153/newsstory [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/images/body-bg.jpg -> images/body-bg.jpg, referer: http://webserver/css/style.css?v=1.0.1 [perdir /var/www/itnews/] strip per-dir prefix: /var/www/itnews/images/body-bg.jpg -> images/body-bg.jpg, referer: http://webserver/css/style.css?v=1.0.1 [perdir /var/www/itnews/] applying pattern '^$' uri 'images/body-bg.jpg', referer: http://webserver/css/style.css?v=1.0.1 [perdir /var/www/itnews/] pass through /var/www/itnews/images/body-bg.jpg, referer: http://webserver/css/style.css?v=1.0.1
related: i've gone through php pages can find , turned on error logging maximum.
i'm getting
notice: undefined index: department in /var/www/itnews/news.php on line 15 notice: undefined index: newsid in /var/www/itnews/news.php on line 18 notice: undefined index: archive in /var/www/itnews/pages/news-archive.php on line 16 notice: undefined variable: page in /var/www/itnews/pages/news-archive.php on line 28
on main page. i'm thinking in php faulting out , redirects failing because php failing resolve variables.
is likely?
this url http://webserver/news/it/153/newsstory
cannot match first rule because of /
@ end.
# not match rewriterule ^news/(.*)/(.*)/(.*)/$ news.php?department=$1&newsid=$2&newstitle=$3 [l] # match rewriterule ^news/(.*)/(.*)/(.*)$ news.php?department=$1&newsid=$2&newstitle=$3 [l]
you can use this tool debug .htaccess
files.
Comments
Post a Comment