I have the following URL:
http://mysite.com/tracks/backing-track-search?artist=TINA-TURNER&action=search&listArtist=true
Which I want to read:
http://mysite.com/tracks/backing-track-search/TINA-TURNER
This is what I'm trying but it simply takes me to http://mysite.com/tracks/backing-track-search
without any of the GET
variables
RewriteRule ^(tracks)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /$1/$2?artist=$3&action=$4&listArtist=$5 [QSA,L]
Is this possible or do I have to include the action
and listArtist
variables in the URL too? (I could probably flag them if they're not there in PHP file but thats easy)
I also tried, which fails:
http://mysite.com/tracks/backing-track-search/TINA-TURNER/search/true
EDIT I think there may be some confusion, my fault...
In the original URL
http://mysite.com/tracks/backing-track-search?artist=TINA-TURNER&action=search&listArtist=true
Notice
...backing-track-search?artist...
Well backing-track-search
is actually a file, backing-track-search.html
not a directory - i simply left off the .html as I have that rule written in the .htaccess
file
What if you did this in .htaccess?
RewriteRule ^backing-track-search/([^/]+) /tracks/backing-track-search.html?artist=$1&action=search&listArtist=true&%{QUERY_STRING} [L]
Then use
http://mysite.com/backing-track-search/TINA-TURNER
I see all 3 variables in $_GET
when I create a php script in /tracks/backing-track-search
, using your 2nd rule in a blank htaccess file in my document root.
What may be going on here is that simply going to /tracks/backing-track-search/something-something
is running the script right off the bat so nothing is getting rewritten (especially if you're using conditions like RewriteCond %{REQUEST_FILENAME} !-f
or !-d
). Then the PATH INFO for the script ends up with a /something-something
in it. You could try renaming the URL to something different, like:
http://mysite.com/tracks/backing-track/TINA-TURNER/search/true
Then your rule would be:
RewriteRule ^tracks/backing-track/([^/]+)/([^/]+)/([^/]+)/?$ /tracks/backing-track-search?artist=$1&action=$2&listArtist=$3 [QSA,L]