Welcome to WebmasterWorld Guest from 50.16.68.229

Forum Moderators: Ocean10000 & incrediBILL & phranque

RewriteRule aid needed

trying to make a journal script "cleaner" for users

   
2:18 pm on Feb 15, 2003 (gmt 0)

10+ Year Member



Noticed that people don't like to see www.server.com/users/USERNAME/journal redirecting to a php script with the username on the end, its not as tidy.

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.

2:58 pm on Feb 15, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



synkronus,

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]

For testing in /~foz, change the rule to:

RewriteRule ^users/(.*)/journal$ /~foz/sonis/index.php?user=$1 [L]

In order for the above to work, the requested URL must end in "journal" exactly, with no file type, slash, or subdirectory path following. If there may be further path inforamtion appended, leave off the "$".

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>

7:33 pm on Feb 15, 2003 (gmt 0)

10+ Year Member



that didn't seem to fix the problem.

will contact server admin asap but ta for the response :)

5:25 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



Hi,

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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month