Domanda

i've searched for this for couple hours before posting the question...

I need to use .htaccess to transform urls that contain /go/[any_filename.mp3]?track into /track.php?[any_filename.mp3]

so, for example, input would be:

http://example.com/go/demo.mp3?track

user gets redirected to

http://example.com/track.php?demo.mp3

the /go directory is actually something i reserved to do this trick, so there's nothing actually there. The current .htaccess configuration is

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L]
È stato utile?

Soluzione

Try adding these rules to the htaccess file in your document root:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^track$ 
RewriteRule ^go/([^/.]+\.mp3)$ /track.php?$1 [L,R]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top