View Full Version : htaccess clean URL help

06-17-2010, 07:26 AM
I have been attempting to get my urls more friendly. I have been reading on using the .htaccess mod_rewrite to do this, but have been unable to get anything to work.....other than disabaling my thumbnails. :confused:

I have been trying to change this


To this


I recently found somthing about adding some php code to pages, and am still reading on that. Any information would be greatly appreciated. :)

06-17-2010, 07:55 AM

I just summarized the long thread today-- see the last post for the 'simple' version.

I don't know if that will help you, but it would get around the complexity of htaccess. You'll need to include the right image format headers so that PHP serves the images as images rather than text, if that's necessary.

If you don't want to do it that way (you want to use the traditional approach with htaccess), then you will have some major problems with that desired URL: "-title" is confusing: do you want this displayed on the page? That'll mean using another get variable like &title=title.
Or if you just want to drop that, it'll mean more parsing to get it out of the way.
Same with "image-"... you'll have to remove this... why have it in the first place?
And the biggest problem is 'nine'-- can you not use numerals? You'll have to add a lot of complex regex rules for replacing spelled out numbers with numerals. The same applies in PHP, though you'll have more options there.

06-17-2010, 09:06 PM
Thanks, im gonna check out that other thread you suggested.

As for the( image-nine-title )

WHat I meant by that is replace that with the current title of the page.


would be

would be

06-17-2010, 10:53 PM
Ah, that makes a lot more sense.
However, this still is going to present a major problem: htaccess isn't going to know how to redirect based on "title". So I suggest that you use .htaccess like in my link or in a more traditional method that forwards the /image-title part as ?image=image-title to the PHP page.
Then use $_GET['image'], compare it to your database (or other list) and use the right image.

You're looking at two separate problems: 1. how do you change the url, 2. how do you convert the image title to the image filename?

Is there some reason you don't want to save the images with those filenames? You could convert from lowercase with underscores (image_title.jpg) to capitalized with dashes: Image-Title, or whatever you'd like.

06-20-2010, 04:54 AM
Well, I think im startin to get some were after reading your tutorial. Thanks a bunch.

I really don't care if - or _ is used. Mainly just want something nicer looking. If I can get it to look something like http:/funigifs.com/pp/image/60 that would be a great start while I read up on the subject.