help with mod_rewrite

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

help with mod_rewrite

Post by vigge89 »

I've checked out mod_rewrite, and I thought that i'd give it a try and give my site user/search-engine -friendly URLs. The problem is that it does not matter what I do, while trying to access the pages i get 404 errors.

Here's my .htaccess which is lying in the root of the htdocs folder:

Code: Select all

ErrorDocument 404 /index.php?p=404

RewriteEngine On
RewriteRule ^/(їa-z0-9_-]+) /index.php?p=$1
(I would have changed the ErrorDocument 404 to /404/, if it would've work but it doesn't)

How I want the URLs to work (examples):
http://vigge.ath.cx/ (root) or /start/ - leads to index.php?p=start (or just index.php for root)
/files/ - leads to /index.php?p=files (ie, files section)
/econtent/?edit=somepage or /econtent/somepage/ - leads to /index.php?p=econtent&edit=somepage
As you can see, I want the query-string to be turned into a user-friendly url-part, but I would prefer it be possible to use the normal query-string way too (but it's not too important).

How it currently works:
http://vigge.ath.cx/ (root) or /?p=start - leads to index.php?p=start (or just index.php for root)
/?p=files - leads to /index.php?p=files (ie, files section)
/?p=econtent&edit=somepage
Any ideas?
Thanks in advance
Last edited by vigge89 on Fri Aug 27, 2004 10:24 am, edited 3 times in total.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

anyone? :(
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

also, im running Apache 2.0.50
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

My current .htaccess-file, which just leads me to the 404 page when trying to access /files/, /links/ or any other section...
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i've got ithe page-part to work now, but i had to use /p/pagename/ to get it too work, here's the .htaccess:

Code: Select all

ErrorDocument 404 /index.php?p=404

RewriteEngine On
Options +FollowSymlinks

RewriteBase /
RewriteRule ^p/(їa-z0-9_-]*)/ /index.php?p=$1
RewriteRule ^/$ /index.php
However, when trying to access something like /p/files/?id=1 , it doesn't work, the get-request doesn't seem to be set, does anyone know how to fix this?


Edit: i finnaly got it too work, using this code:

Code: Select all

ErrorDocument 404 /index.php?p=404

RewriteEngine On
Options +FollowSymlinks

RewriteBase /

RewriteRule ^p/(їa-z0-9_-]*)$ /index.php?p=$1
RewriteRule ^p/(їa-z0-9_-]*)\/(.*) /index.php?p=$1&$2
RewriteRule ^p /index.php
this lets the visitor access a page with the following address:
/p/pagename/
and if more get-variables are used, add it to the end:
/p/pagename/variable=something

just a question, would this work for search-engines?
Post Reply