Hello, I'm having trouble with htaccess. I'd like to re-write a long url to short one, while allowing for pagination. https://www.mydomain.com/profile/profile.php?username=username to https://www.mydomain.com/username However, the first url could be. https://www.mydomain.com/profile/profile.php?username=username&page=1 I've got a couple lines that I tried, but neither work, and I'm not sure if they're on the right track. They're just snippets I found while Googling. Any help getting this right would be greatly appreciated. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.bangsinglez.com/$1 [R,L] RewriteRule ^(.*)$ /profile/profile.php?username=$1 [QSA] Code (markup):
May be replace [QSA] flag with %{QUERY_STRING} would help? RewriteRule ^(.*)$ /profile/profile.php?username=$1&%{QUERY_STRING} Code (markup):
Wait, the issue has been half fixed. It causes an issue though. Mp3s will not play on the new urls. There are no files in the url though, they're fetched from the database with php and the urls are created in html. I have no idea why the mp3s won't play. I'll show the new htaccess code. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^([^/]*)$ profile/profile.php?username=$1 [L,QSA] Code (markup): If you view source on the two pages you will see the url paths to the mp3s are identical. Not sure what's causing the problem. http://www.bangsinglez.com/scrimige http://www.bangsinglez.com/profile/profile.php?username=scrimige Code (markup):
I've fixed this issue, but the site was rewriting everything to profile and I was getting my "profile not found error." as if the username value wasn't present or didn't hold a chosen username. Can you tell by the code here what is causing that, or if it's writing everything to profile.php and why? RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^([^/]*)$ profile/profile.php?username=$1 [L,QSA] Code (markup):
RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC] RewriteCond %{HTTP_HOST} ^(.+)\.mydomain\.com$ [NC] RewriteRule ^.*$ http://www.mydomain.com/profile.php?username=%1 [L]