Jump to content

htaccess Issue


kickstart

Recommended Posts

Hi

 

I had an htaccess issue which I hope someone can help me with:-

 

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} ^.*\.gif$
RewriteRule ([a-zA-Z]+)\.gif$ GrabImage.php?username=$1

 

The idea is that any request to a gif in that directory should be passed to GrabImage.php.

 

However while if I invoke GrabImage.php directly it works fine, if I specify an image name instead  I get a 404 error. If I change "GrabImage.php" to "/Index.php" in the script it redirects it successfully to the root index script (happens to be a phpbb forum) for that domain.

 

If I specify a gif in that directory with a name which is not just alphabetics (so the RewriteRule is not met) then the image is served perfectly. If I rename the image and try again with the new name (which the RewriteRule meets) then I get a 404 error.

 

I suspect I have missed something simple here, and it does work fine on my wamp setup on my desktop machine, just not when I upload it.

 

Thanks in advance.

 

All the best

 

Keith

Link to comment
Share on other sites

Hi

 

Had more of a play.

 

The directory is like:-

 

/publichtml/sitedirectory/subdirectory1/subdirectory2/

 

subdirectory2 contains the GrabImage.php script and the .htaccess file. Also an Index.php that is a clone of GrabImage.php.

 

If I try the following it doesn't work. Just get a 404 error

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^.*\.gif$
RewriteRule ([a-zA-Z]+)\.gif$ Index.php?username=$1

 

If I try the following it pics up the Index.php from that sites directory (ie /publichtml/sitedirectory/Index.php)

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^.*\.gif$
RewriteRule ([a-zA-Z]+)\.gif$ /Index.php?username=$1

 

If I try the following it does actually work.

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^.*\.gif$
RewriteRule ([a-zA-Z]+)\.gif$ /subdirectory1/subdirectory2/Index.php?username=$1

 

"RewriteBase /" appears to have no effect.

 

My understanding was that the rewrite rule was relative to the local directory unless specified otherwise but that doesn't appear to be the case.

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.