I'm in HTACCESS RuleRewrite hell, please send water

nonchessguy

Registered Member
Joined
Nov 2, 2008
Messages
62
Reaction score
26
Hi all,

I'm near the end of my rope but before I tie it into a noose I thought I'd reach out for help. :)

I have set up my article system to show SEO friendly URL's and I need to use a RewriteRule to let the server know which file to deliver when the user clicks the link.

I always learn by example but I haven't been able to figure this one out.

This is what I have:

This is how the link looks:
Code:
http://www.exampleonly.net/news/foreclosure/787/this-is-the-new-article.html

This where it needs to look:
Code:
http://www.exampleonly.net/news.php?x=foreclosure&article=787

This is my entire .htaccess file:
Code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^news/foreclosure/([0-9][0-9])/([A-Za-z0-9-]+).html$ /news.php?x=foreclosure&article=1$

I don't want to confuse you or make you think that I'm completely confused, (unless I really am just way out there), so let me just say that where it has the ([A-Za-z0-9]+) this is the SEO friendly article title that's pulled from the database like all the other elements. I don't need it in the rewrite because the article number is what is used to identify the article.

Please help or I will lay down in front of the lawnmower like that guy in "The Happening". If you've never seen the movie then don't; it's just an hour and a half of bad filmaking with a moderately high gore factor.

Thanks,

JD
 
Try this and see if it works for you.

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^news/foreclosure/([0-9]+)/([A-Za-z0-9-]+).html$ /news.php?x=foreclosure&article=$1 [NC,L]

If you want the address in the address bar to show the redirected URL then change the [NC,L] to [NC,R].

Hope that helps you out
 
Thanks Zone! I had my head in the oven when my email alert sounded. Glad I checked!

This is the final code after playing with yours for a while...
Code:
RewriteRule ^([a-zA-Z]+)/foreclosure/([0-9]+)/([a-zA-Z0-9\-_.]+)\.html$ $1.php?x=foreclosure&article=$2&$3 [NC,L]

For some reason I kept getting a 500 error when I had an abandoned variable so I just dumped it at the end.

Thanks again for your help! Rep added.

David
 
Back
Top