Solved

RewriteRule

Posted on 2010-08-21
5
197 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:Serellyn
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:HackneyCab
ID: 33493525
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.
0
 
LVL 1

Author Comment

by:Serellyn
ID: 33494813
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.
0
 
LVL 1

Author Comment

by:Serellyn
ID: 33495274
Okay, I fixed it myself, here it is.

RewriteRule ^artist/([a-z]{1})+/$ index.php?browse=$1
0
 
LVL 16

Accepted Solution

by:
HackneyCab earned 500 total points
ID: 33495437
My mistake, sorry. Without the parentheses, the $1 doesn't actually refer to anything.

I still think that a URL like /index.php?artist=c or /artist.php?name=c looks fine. The craze for "SEO" rewrites leaves me cold. For instance, /artist/c/ is two sub-directories deep, whereas /artist.php is in the top-level directory. Word used to be that Google rated deep-directory documents lower than top-level documents. This may have changed, but I still regard these "pretty" URLs with caution.
0
 
LVL 1

Author Comment

by:Serellyn
ID: 33495465
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bootstrap 3 and Angular 2 12 53
Sums of coloumns in html/java 15 67
Why is this panel heading creating extra space 2 35
Apply tab index in forms 6 33
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now