homepage Welcome to WebmasterWorld Guest from 54.198.130.203
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
RewriteRule aid needed
trying to make a journal script "cleaner" for users
synkronus




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

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.

 

jdMorgan




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

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>

synkronus




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

that didn't seem to fix the problem.

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

vchopra




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved