View Full Version : mod rewrite (PHP URL)
Maximus
01-13-2007, 10:08 PM
Hey, I know almost nothing about the proper usage of mod rewrite, so I would appreciate it if someone could help me out.
I need:
http://www.site.com/index.php?p=view&article=article name here
Converted (via mod rewrite) into
http://www.site.com/article/article-name-here/
Thanks in advance!
RewriteEngine on
RewriteRule ^/article/([^/]+)/?$ /index.php?p=view&article=$1... if I remember correctly.
Maximus
01-13-2007, 10:42 PM
Doesn't seem to be working :(
Everything is set up correctly?
alexjewell
01-13-2007, 10:54 PM
This is what I've seen in the past. I've never used it, but it's worth a try?
RewriteEngine On
Options +FollowSymlinks
RewriteRule ^index/(.*).php index.php?action=$1
Maximus
01-13-2007, 10:58 PM
well after reading through several tutorials, and your post, I am very confused.
The links on my page will be:
http://www.site.com/article/article-name-here/
Now obviously that is not a real url, because those "directories" don't exist.
Thats why I need the above to be interpreted by the server as:
"http://www.site.com/index.php?p=view&article=article name here". I don't want it to display that ugly url though. I mean the whole point of this is to "nicen" the url (be it for people or search engines).
RewriteRule ^index/(.*).php index.php?action=$1No, that expression is wrong for the situation you described. You'd want:
RewriteRule ^article/([^/]+)/ index.php?p=view&article=$1
Maximus
01-13-2007, 11:06 PM
Ok that seems to work.
Sadly the new (static) page seems to take almost 3 seconds to load (before it displays anything), Im guessing thats because of the re-write action.
alexjewell
01-13-2007, 11:08 PM
Thanks Twey
I think he's misunderstanding though...how it works.
First of all, you're using Apache right?
Second, did you set up a httpd.conf AND a .htaccess file?
alexjewell
01-13-2007, 11:08 PM
Ok, nevermind. Haha. Maybe he did understand.
alexjewell
01-13-2007, 11:09 PM
And yes, Max, that is a downside to using this. There are several reasons I don't use it, personally, and that is one of them. However, it is GREAT for search engines and prettier url's.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.