Jump to content
Sign in to follow this  
real_illusions

Htaccess Rule Not Working

Recommended Posts

Hi all, I have a rule setup thats similiar to another that works, but this one doesn't, and I cant work out why. Rule is as follows: RewriteRule ^latestnews-([a-zA-Z]+)/?$ newsitem.php?item=$1 [NC,L] Where the ending variable is used to get a database item, and thus displays the right content on the page, and is also displayed in the friendly URL. For example: /newsitem.php?item=newsitem-goes-here would appear as: /latestnews-newsitem-goes-here But instead, I get a 404 error. Now, I have a similiar setup on another page but that uses PHP switch statements to determine the content as the amount of content is quite small compared to this one that uses a database. The un-friendly URL with the variable in works fine, displays the content all ok, its just when accessing the friendly URL that it all goes a bit wonky and spits out a 404. Any ideas?

Edited by real_illusions

Share this post


Link to post
Share on other sites

On your webpage with the friendly URL, what does it exactly look like? is it actually: /latestnews-newsitem-goes-here ?

Share this post


Link to post
Share on other sites

I think you're missing a hyphen in part of your expression:([a-zA-Z-]+)You might also want to include numbers there too.

Share this post


Link to post
Share on other sites

Ah, that was it, the - missing in the expression. Always something so simple you overlook and then someone else points it out and you feel like an idiot. Thanks ;)

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...