I have created .htaccess
file like this, here I am searching for DB
string, if uri contains DB
string then write complete uri
to variable url
and redirect, so far I tried this.. I don't know much about mod_rewrite and htaccess.
Options +FollowSymlinks
RewriteEngine on
# If URI contains string DB then encode http_host and request uri and
# send to http://host.domain.org/site2/index.php with new variable url=encodedstring
RewriteCond %{REQUEST_URI} /DB/
RewriteRule ^ http://host.domain.org/site2/index.php?url=%{HTTP_HOST}%{REQUEST_URI} [NE]
Suppose if my url is
http://host.domain.org/site2/DB/process.php?name=x&y=10
I would like url variable to be this
$ echo 'http://host.domain.org/site2/DB/process.php?name=x&y=10' | base64
aHR0cDovL2hvc3QuZG9tYWluLm9yZy9zaXRlMi9EQi9wcm9jZXNzLnBocD9uYW1lPXgmeT0xMAo=
I want url should be like this
http://host.domain.org/site2/index.php?url=aHR0cDovL2hvc3QuZG9tYWluLm9yZy9zaXRlMi9EQi9wcm9jZXNzLnBocD9uYW1lPXgmeT0xMAo=
I don't know this is possible or not in .htaccess kindly someone help me
I even tried to replace all slashes to hypen like this at last
slash.sh
#!/usr/bin/env bash
sed -u 's/\//-/g'
.htaccess file
RewriteCond %{REQUEST_URI} /DB/
RewriteMap slash prg:/var/www/virtual/slash.sh
http://host.domain.org/site2/index.php?url="${slash:%{HTTP_HOST}}${slash:%{REQUEST_URI}}" [L]
Suppose if my url is
http://host.domain.org/site2/DB/process.php?name=x&y=10
I want url should be like this
http://host.domain.org/site2/index.php?url="http:--host.domain.org-site2-DB-process.php?name=x&y=10"
I received an error 500 Internal Server error
So finally neither base64 nor slash replace worked for me.. its my hard luck
Thanks.