PDA

View Full Version : Mod Rewrite, to Remove Spaces



Emancipator
10-31-2004, 04:44 PM
I have a page, here is a basic example, That I am using mod rewrite to get rid of most the crap in the url, and make it spiderable for my own movie search engine.

http://www.moviesonline.ca/gallery_details_movie.php?movie=Seed%20of%20Chucky

Using mod rewrite i made it into this

http://www.moviesonline.ca/_Seed%20of%20Chucky.htm

Now my dilemna is HOW do I later my mod-rewrite to get rid of the %20 and make it a DASH instead ( - )

the line in my htaccess is


RewriteRule _(.*)\.htm$ /gallery_details_movie.php?movie=$1

Thanks Guys! New to mod rewrite getting the hang of er with some help.

alien
10-31-2004, 07:50 PM
The RewriteRule will work for dash (-) as well. What you need to do is modify the php scripting part to return the %20 as dash (-).

Todd W
11-06-2004, 05:02 PM
mod_rewrite doesn't make the URLs your PHP script does.. or whatever you use to make the links.

I don't like having spaces in the URL at all. Why not remove spaces and replace them with - then simply have your gallery_details_movie.php file replace - with spaces. I know it's ultimately the same thing, but I prefer - in the address rather than %20

I have a clean_title() php function I wrote for converting certain characters into nothing or into -'s if you want.. It can get tricky depending on the titles of the movies you review when looking them up by the title, that's why I reccomend using something like this for the mod_rewrite URL.

# would represent the row ID of the movie Seed of Chucky in the mysql database, an the gallery_details_movie.php can lookup what movie to get info about based on the unique ID # rather than having to re-parse the movie title, and lookup based on the string which could have been translated back incorrectly. #'s are just so much easier to deal with :)

http://www.moviesonline.ca/n#-Seed-of-Chucky.htm