.htaccess — Variable location of affected folder -
i have php script generate placeholder images, placehold.it service. wanted custom 1 prevent latency occurs free online services.
i have included script inside of folder ./assets/placeholder/ in personal front-end boilerplate. why need .htaccess adapts current location of placeholder folder, not root.
the script takes following parameters: d (dimension, eg. 400, 250x100), bg (background color), color (text color) , text.
ideally, url work following ./assets/placeholder/300x200/eaeaea/333333?text=test
, text being regular var.
here .htaccess put while ago. works provided file in root directory:
rewriteengine on rewriterule ^#([^/]*)/([^/]*)/([^/]*)$ index.php?d=$1&bg=$2&color=$3 [qsa]
in 1 sentence, if move file (index.php) root /some/other/dir/index.php, want .htaccess file still function without have change rewritebase or anything.
i have found this article on matter, don't have enough knowledge on subject make fit case.
thanks in advance!
update: decided move .htaccess file root of project. thing not working adding of / @ end, before ?
## turn mod_rewrite engine on ## rewriteengine on # no trailing / ? rewritecond %{request_uri} !(.*)/$ # add slash. rewriterule assets/placeholder/(.*)$ assets/placeholder/$1/ [l,r=301] # map parameters vars rewriterule assets/placeholder/?([^/]*)/?([^/]*)/?([^/]*)/$ assets/placeholder/index.php?d=$1&bg=$2&color=$3 [qsa]
change url .assets/placeholder/300x200/eaeaea/333333&text=test
.assets/placeholder/300x200/eaeaea/333333?text=test
if want qsa flag runs.
and try code :
rewriteengine on rewriterule ^assets/placeholder/([^/]*)/([^/]*)/([^/]*)$ index.php?d=$1&bg=$2&color=$3 [qsa]
try code redirection url end slash :
rewritecond %{request_uri} !^([^/]*)/$ rewriterule assets/placeholder/(.*)$ assets/placeholder/$1/ [l,r=301]
Comments
Post a Comment