Mod Rewrite not working 100%
First off, I use 1and1 servers...
Heres what I have, and what I want...
What I have...
http://www.sublimestylee.com/news/?id=500
What I want...
http://www.sublimestylee.com/news/500/
This may seem like an easy fix, but I have been playing with it for hours and I am stumped.
Here is the code...
RewriteEngine on
RewriteBase /pages/
RewriteRule news_story_display\.php$ /news/$1 [R,L]
It may seem like I just need to add ?id= after the .php part in the 3rd line, but it doesn't work. If I include it so the code looks like...
RewriteEngine on
RewriteBase /pages/
RewriteRule news_story_display\.php?id=$ /news/$1 [R,L]
The URL's are now like the original, before I edtied my .htaccess file and display like...
NOTE: I have used escape characters infront of the ? and such with no luck either.
http://www.sublimestylee.com/pages/news_story_display.php?id=500
pr0gr4mm3r posted this at 02:03 — 19th December 2007.
He has: 1,502 posts
Joined: Sep 2006
This should do it:
RewriteEngine on
RewriteRule ^news/([0-9]+)$ news/?id=$1 [L]
sublimer posted this at 06:46 — 19th December 2007.
They have: 41 posts
Joined: Aug 2006
Nope, I implemented that and there is no difference in the URL, they are still like...
http://www.sublimestylee.com/pages/news_story_display.php?id=42
pr0gr4mm3r posted this at 22:07 — 19th December 2007.
He has: 1,502 posts
Joined: Sep 2006
The original URL will still work. When you use the rule that I posted, http://www.example.com/news/?id=123 will work in addition to http://www.example.com/news/123
JeevesBond posted this at 13:03 — 19th December 2007.
He has: 3,956 posts
Joined: Jun 2002
This is little more than an edited copy/paste:
RewriteRule ^news/(.*)$ news_story_display.php?id=$1 [L,QSA]
'I blagged it from Drupal (as it's ReWrite malarkey is pretty similar to what you're doing). Give it a try; not sure about the QSA rule at the end, according to the Apache docs:
*** EDIT ***
Is that 404 page your doing, or the hosts?
a Padded Cell our articles site!
akopayan posted this at 15:34 — 28th January 2008.
They have: 106 posts
Joined: Nov 2006
I think it's the host.
tummy posted this at 15:17 — 13th March 2008.
They have: 121 posts
Joined: Mar 2007
Thinks it's the host.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.