Forum Moderators: phranque
The bbcode filter wont parse links that dont end with png/jpg/gif/etc. This stops me from passing GET parameters, and having a .php ending image.
The solution is to use a rewrite and pass the parameters as subdirectories, and i've figured that out, but i'm having problems making it dynamic since installation location will vary.
I want the .htacces to be in my softwares directory, not their root directory, and I want to avoid them having to alter it.
for example, the dynamic image is saved at installdirectory/phpbbsignature.php and needs a ?name=bob to gen bobs signature.
Currently i'm using
RewriteRule ^phpbbsig/([A-Za-z0-9/-]+)/mysig.png$ /phpbbsignature.php?name=$1 [L]
This works on my test site as i have a subdomain that it is installed in, so when i visit the subdomain...
[subdomain.mysite.com...]
it changes to
[subdomain.mysite.com...]
The problem is that I have no idea where the server admins installing my stuff will be putting it and mod_rewrite seems to strip leading directory names off when .htaccess is in a folder. For example if I visit the same exact page by typing out the folder name the subdirectory is mapped to (i.e. sobdomain.mysite.com points to mysite.com/subdomain) I get the following.
[mysite.com...]
it changes to
[mysite.com...]
it strips out the subfolder name...
I understand I can fix this by putting .htaccess in the root directory, but not all my users are very savvy, and if there is already one there I would have to be offering extra support in helpng them merge the two files. If I leave it in the install directory then I would have to be offering them support still to modify the file to add on the subfolder names....
Is there an alternative to add the stripped subfolder names back on, and it be dynamic even if theyinstall it in [newsite.com...]
I've really been hunting around and trying alot of stuff. I've tried several things unsuccesfully... if anyone has a solution I would really appreciate it.
RewriteCond %{THE_REQUEST} ^GET\ ([.+])/phpbbsig/[.+]$
RewriteRule ^phpbbsig/([A-Za-z0-9/-]+)/mysig.png$ %1/phpbbsignature.php?name=$1 [L]
to illustrate what I would expect/want this to do here are some examples in the order of:
.htaccess location
requested url
rewrite url
#1
[mysite.php...]
[mysite.php...]
[mysite.php...]
#2
[subdomain.mysite.php...]
[subdomain.mysite.php...]
[subdomain.mysite.php...]
basically htaccess will be in whatever folder phpbbsignature.php is in, and its parent folder could be ANYWHERE since this released software
Did i even get close?
RewriteCond %{THE_REQUEST} GET\ (.+)phpbbsig/
I like the range from yours, i've heard its faster that way, but for some reason it had some problems with the leading /, i guess it starts with "http". I dunno... anyway here is the final product for anyone else that stumbles by this thread. Thanks very much for the help jim.
RewriteCond %{THE_REQUEST} ^GET\ ([^#?\ ]+)phpbbsig/
RewriteRule ^phpbbsig/([A-Za-z0-9/\-]+)/mysig\.png$ %1/phpbbsignature.php?name=$1 [L]
So, if possible, please try to figure exactly why there is a problem -- You really need to start the substitution path with a slash, rather that with "whatever the client sends" as I did in the example I posted.
By the way, THE_REQUEST is the HTTP request line as received from the client -- and exactly as it appears (usually) in your raw server access log file. e.g
GET /abc/def/phpbbsig/ HTTP/1.1
Jim