Forum Moderators: phranque
I've looked around a few posts here and thought the apache RewriteRule a few of you mention would be ideal for what I would like to happen...
I'd like www.server.com/users/USERNAME/journal to point users to www.server.com/sonis/index.php?user=USERNAME.
My .htaccess is currently:
RewriteEngine On
RewriteRule ^users/(.*)/journal$ sonis/index\.php?user=$1
But that's not working. Any ideas?
Note: I'm currently avoiding putting this .htaccess file anywhere important so its stored in /~foz/ on the server along with the sonis script but in the future I'd like it to do exactly what I wrote at the top.
Yes, don't "escape" characters by preceding them with "\" unless they are in patterns to be matched. The
"\.php" in your RewriteRule's target URL is likely causing problems.
You may also need to add the Options line to the beginning of your rewrite section.
I'd like www.server.com/users/USERNAME/journal to point users to www.server.com/sonis/index.php?user=USERNAME.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^users/(.*)/journal$ /sonis/index.php?user=$1 [L]
RewriteRule ^users/(.*)/journal$ /~foz/sonis/index.php?user=$1 [L]
Check your raw server error logs for more information if the above does not work.
This Introduction to mod_rewrite [webmasterworld.com] post is very useful and has links to more reference material.
HTH,
Jim
<edit>Added [L] flag - See referenced thread.</edit>
I have been trying to get mod_rewrite() function to work. It works fine when cookies are enabled and there is session ID added to the URL. But the problem comes in when the cookies are disabled. PHP adds session ID at the end ofthe URL, which is disregarded by the rewrite rule and then we loose track of the session . Keeping track of session ID is important since we have a shopping site.
Please help.
Thanks
Vivek