SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Feb 15, 2005, 15:23 #1
- Join Date
- Sep 2004
- Location
- Denver
- Posts
- 111
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Need some simple (i think) mod rewrite help
I've been trying to figure this out for a while now but I'm not having any luck.
Here's what I'm trying to do.
example.com/directory/index.php?article-title
rewritten to just...
example.com/directory/article-title
I'm really new to mod rewrite and I've read several tutorials but still haven't gotten anything working. Any ideas out there? Thanks.Last edited by tristankelley; Feb 15, 2005 at 17:07.
-
Feb 15, 2005, 15:32 #2
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
tristan,
YOU have to rewrite your links in your webpages yourself! Mod_rewrite will rewrite back if you have it done correctly, i.e., changedirectory/article-title to index.php?article-title=article-title.
Have a look at http://www.datakoncepts.com/seo for more details on setting up Apache and using mod_rewrite.
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
-
Feb 15, 2005, 17:05 #3
- Join Date
- Sep 2004
- Location
- Denver
- Posts
- 111
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmmm. I guess I don't have any clue about mod rewrite.
Does Sitepoint use mod rewrite to get URL's like:
http://www.sitepoint.com/article/push-pull-best-cms
Thanks.
-
Feb 15, 2005, 17:09 #4
- Join Date
- Mar 2003
- Location
- England, UK
- Posts
- 2,906
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Give me a PHP url and what you want it converted into using mod_rewrite. And I'll see what I can do
-
Feb 15, 2005, 17:20 #5
- Join Date
- Sep 2004
- Location
- Denver
- Posts
- 111
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have url's like:
example.com/directory/index.php?title=article-title
I would like them to look like
example.com/directory/article-title
Does that make sense?
-
Feb 15, 2005, 17:30 #6
- Join Date
- Mar 2003
- Location
- England, UK
- Posts
- 2,906
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok first of all I'm assuming:
a) You have .htaccess files enabled on you server
b) You have mod_rewrite enabled on your server.
Make a filename called '.htaccess' and place in it:
Code:RewriteEngine On RewriteRule ^([A-Za-z-]+)/?$ index.php?title=$1 [L]
-
Feb 15, 2005, 19:41 #7
- Join Date
- Feb 2002
- Location
- Auckland
- Posts
- 14,692
- Mentioned
- 20 Post(s)
- Tagged
- 3 Thread(s)
tristan,
Dean's code is perfect IF you don't include any character other than the upper and lower case alphabet and the hyphen (dash). Be SURE that you stick to that in naming your titles (for the links).
Regards,
DKDavid K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks