Mr Chris Posted March 28, 2008 Share Posted March 28, 2008 Hi All, Not sure i'm posting in the right forum but i'll try here... I have a mod-rewrite going on which converts a dynamic story like: http://www.thewebhhhh.org/section.php?sec=2&story_id=3276 to http://www.thewebhhhh.org/article/2/3276/the-title-in-the-story Options +FollowSymLinks -MultiViews RewriteEngine On RewriteRule ^article/([0-9]+)/([0-9]+)/([a-z0-9\-]+)/?$ section.php?sec=$1&story_id=$2 [QSA,NC,L] and then in my php template replacing the story headine for the URL to encorporate - $clean_headline - str_replace(' ', '-', strtolower($header)); However, some headlines may contain special characters like: \ ? & £ ! " % _ etc... So i'm confused as to how to fix this. For example I currently have a headline which reads: £1000 pounds Which throws up a 404 because of the £? Can anyone help? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/98295-modrewrite-with-php/ Share on other sites More sharing options...
wildteen88 Posted March 28, 2008 Share Posted March 28, 2008 You'll need to use urlencode to pass special characters over the url. Now this will cause your nice clean urls to become messy, eg: %3Fh%3D%A31000-pounds Now I rremember you from last time, as I got you to change your query so it retrieves the story from the headline field rather than the id field in the database. What I recommend you to do instead is create another field and call this new field urlAlias. Now in this field you store a modified/simplified version of the actual headline which will not store any special characters. This will allow for your urls to stay clean and simple. You'll need to modify your existing code to to fetch/receive the urlAlis rather than the headline for displaying/retrieving the headline in the url. Quote Link to comment https://forums.phpfreaks.com/topic/98295-modrewrite-with-php/#findComment-503048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.