Link to home
Start Free TrialLog in
Avatar of Serellyn
Serellyn

asked on

RewriteRule

Hey guys,

I want to rewrite the following link
artist/c/
to
index.php?browse=c

I know it's done in the .htaccess, I just can't figure out how to do this.
Avatar of HackneyCab
HackneyCab
Flag of United Kingdom of Great Britain and Northern Ireland image

Try the following:

RewriteEngine On
RewriteRule ^artist/[a-z]+/$ /index.php?browse=$1

This will do a silent rewrite (so the user's browser will not redirect and change the address shown in the address/location bar). Bear in mind that will cause a problem with images, etc, as the web browser will think it's in a directory called /artist/ which does not actually exist on your server.

Personally, I think index.php?browse=artistname looks fine, but I seem to be in the minority.
Avatar of Serellyn
Serellyn

ASKER

Thank you for the response, but it is not working correctly yet.
the problem is that it's not working correctly yet.

Right now I have

<a href="artist/c/">C</a>

RewriteEngine On
RewriteRule ^artist/[a-z]+/$ /index.php?browse=$1


But the rewrite isn't working, it does not make index.php?browse=c of it.
Okay, I fixed it myself, here it is.

RewriteRule ^artist/([a-z]{1})+/$ index.php?browse=$1
ASKER CERTIFIED SOLUTION
Avatar of HackneyCab
HackneyCab
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I understand what you mean, and I might change it.
if it brings too much trouble, I will change it to normal, so thank you.