play_ Posted February 28, 2010 Share Posted February 28, 2010 This is my first attempt at mod_rewrite. What I'm trying to do is make it so that when the user clicks any mp3 link (example, 1.mp3), mod_rewrites redirects that to download.php I this in .htaccess: RewriteEngine on RewriteRule *.mp3 download.php if I go to http://localhost/1.mp3, the page hangs. Firefox shows the 'loading' sign on the tab, like it's about to load the other page, but it doesn't. any help would be great. thanks Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/ Share on other sites More sharing options...
cags Posted February 28, 2010 Share Posted February 28, 2010 RewriteEngine on RewriteRule ^(.*)\.mp3$ /download.php?id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/#findComment-1019500 Share on other sites More sharing options...
play_ Posted February 28, 2010 Author Share Posted February 28, 2010 Didn't seem to work =( Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/#findComment-1019619 Share on other sites More sharing options...
cags Posted February 28, 2010 Share Posted February 28, 2010 What exactly are you trying to do and how exactly did it not work? Using the code I gave you in my previous post if you typed... http://localhost/blah.mp3 ... the the file the user would actually see is http://localhost/download.php?id=blah, but the address bar should remain as the original URL. If that is not what you want then give... a.) what you are typing in the address bar. b.) what you want the address bar to change to (if at all). c.) what file you wish to actually be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/#findComment-1019626 Share on other sites More sharing options...
play_ Posted March 1, 2010 Author Share Posted March 1, 2010 Sorry for not being so clear. What I'm trying to is, i'll have a link. say <a href="1.mp3">click to download</a> When i click the link, instead of a download dialog popping up or having the file play in the browser, i want the browser to go to download.php What is happening now: When i click the link: - page hangs in firefox. - Chrome plays the mp3 file in browser Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/#findComment-1019643 Share on other sites More sharing options...
cags Posted March 1, 2010 Share Posted March 1, 2010 Hmm.. the code I gave previously should work then, I just tested out on my localhost, works fine. Try closing your browser, restarting Apache and trying again, I've had strange issues with .htaccess files before, some kind of strange caching issue. Quote Link to comment https://forums.phpfreaks.com/topic/193679-page-hangs-with-simple-rewrite-rule/#findComment-1019654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.