Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/98295-modrewrite-with-php/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/98295-modrewrite-with-php/#findComment-503048
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.