Hi.
In htaccess, I’m trying to clean up my URLs and am having trouble. I know that I need to put “RewriteEngine On” which is a start. I think the reason why I’m having a hard time is because all the tutorials I have come across are made for going through just one folder, but in my case I got 2 to go through until you get to a particular article.
In short, I want to make the changes like so:
Before: [noparse]http://www.mgswalkthroughs.com/category/newsarticle.php?record=14[/noparse]
After: [noparse]http://www.mgswalkthroughs.com/category/newsarticle/14[/noparse]
Please help.
RewriteEngine On
RewriteRule ^newsarticle/([^/]*)$ /category/newsarticle.php?record=$1 [L]
rpkamp
June 13, 2011, 10:10am
3
^ what he said.
Although ([0-9]+) would be better (i.e. more correct) than ([^/]*)
RewriteEngine On
RewriteRule ^newsarticle/([0-9]+)$ /category/newsarticle.php?record=$1 [L]
Hmm both of them didn’t seem to work.
I think it must have something to do with my hosting company, HostGator. Thanks for the help though.
rpkamp
June 14, 2011, 8:22am
5
Try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/?newsarticle/([0-9]+)$ /category/newsarticle.php?record=$1 [L]
If that doesn’t work I’m out
Still nothing. I’m pretty sure it’s my hosting. Unless I’m suppose to change the link, but I’m sure it’s suppose to do it on it’s own?
rpkamp
June 15, 2011, 7:33am
7
No you ~ are ~ supposed to change the links. Apache only makes sure your new urls work; it doesn’t rewrite your html.
So instead of
newsarticle.php?record=<?php echo $row_mgsnews['id']; ?>
I put:
newsarticle/<?php echo $row_mgsnews['id']; ?>
?
Sorry I’m new to this lol
Well it’s not working sir
I applied the news link in the titles for now (instead of the “Read More” buttons). It just goes to a messed up version of my 404 page.
rpkamp
June 15, 2011, 10:17pm
11
Could you please try the test described on Apache’s mod_rewrite to see if mod_rewrite is working on your server?