Knowledgebase

htaccess rewrites

Posted by Adam Hallett, 12-28-2007, 03:58 PM
I want to convert download.php?hash= to /downloads/hash The hash query variable is 32 characters in length and composed of both upper case and lowecase letters and numbers. This is what I have so far, but it isn't working. RewriteEngine on RewriteRule ^download.php?hash=(.*)$ /downloads/$1

Posted by aldo, 12-28-2007, 05:46 PM
I think your doing it backwards =P RewriteEngine on RewriteRule /downloads/$1 ^download.php?hash=$1 At least thats how I do mine...

Posted by Adam Hallett, 12-28-2007, 06:08 PM
That doesn't appear to be converting this to /download/0cc...... test

Posted by aldo, 12-28-2007, 07:42 PM
Have you uh tried test ? I dont know much about htaccess but you have to then change the URLs itself, htaccess then just makes a cover up.

Posted by Adam Hallett, 12-29-2007, 12:29 PM
I just tried that and it didn't work. I used the code you provided and I've got a blank php script named, "download.php" in the directory.

Posted by dmspilot, 12-30-2007, 03:11 AM
What do you mean, "it didn't work." You are going to have to be more specific than that if you want help. Did you get a blank page? 500 Internal Server Error? 404 File not Found Error? What? What did your server access and error logs say? Right, the first address us the "fake" one and the second is like the "real" one. But it should be: RewriteRule ^downloads/(.+)$ download.php?hash=$1 or better yet since if the hash is always 32 alphanumeric characters long: RewriteRule ^downloads/([a-ZA-Z0-9]{32})$ download.php?hash=$1 When you are debbuing it is helpful to put an [R] in the RewriteRule which will send a redirect to your browser (and so the url in the address bar should change) rather than silently rewriting it. RewriteRule ^downloads/(.+)$ download.php?hash=$1 [R]



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
html and css (Views: 628)


Language:

Client Login

Email

Password

Remember Me

Search