RewriteMap Problem!

New to mod_rewrite? This is a good place to start.

RewriteMap Problem!

Postby Falcon » Sat Sep 05, 2009 6:27 pm

Hello!

I'm trying to change a numeric ID into a name/title.
Note: i'm working on LocalHost (everything seems enabled)

First i put my rewritemap in httpd.conf, and looks like this:

Code: Select all
<Directory />
    RewriteMap name2id txt:/PHP/map.txt
    RewriteRule ^([^/]+)\.html$ /profile.php?lookup=${name2id:$1|0} [QSA,L]
</Directory>


and another version is this:

Code: Select all
<Directory "E:/THEMES/localHOST/wamp/www/">

    RewriteMap name2id txt:/PHP/map.txt
    RewriteRule ^([^/]+)\.html$ /profile.php?lookup=${name2id:$1|0} [QSA,L]

</Directory>


and none of them is working, i even put the RewriteRule in .htaccess and nothing. (tells me that "The requested URL /profile.php was not found on this server.")

if take rewriterule from htaccess tells me that "The requested URL /PHP/falcon.html was not found on this server."

The direct link to profile.php and map.txt is in:
Code: Select all
E:/THEMES/localHOST/wamp/www/PHP


and in map.txt i have just this:

Code: Select all
falcon 1


my name and my id

Please tell me what i'm doing wrong....
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Sun Sep 06, 2009 3:38 pm

Try
Code: Select all
<Directory "E:/THEMES/localHOST/wamp/www/">
    Options +FollowSymLinks

    RewriteEngine On


    RewriteMap name2id txt:E:/THEMES/localHOST/wamp/www/PHP/map.txt
    RewriteRule ^([^/]+)\.html$ /PHP/profile.php?lookup=${name2id:$1|0} [QSA,L]
</Directory>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Mon Sep 07, 2009 1:22 am

When i use the above RewriteMap and RewriteRule, and restart WampServer, apache doesn't start and gets hungup on
"RewriteMap name2id txt:E:/THEMES/localHOST/wamp/www/PHP/map.txt".

But when i remove "RewriteMap" all gets to normal...

That means that RewriteMap, doesen't work on wamp server ?
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Mon Sep 07, 2009 10:40 am

Is it the correct path?

Try the path in quotes
Code: Select all
txt:"E:/THEMES/localHOST/wamp/www/PHP/map.txt"
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Mon Sep 07, 2009 10:48 am

Same thing! and yeah, thats the correct path
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Mon Sep 07, 2009 12:46 pm

You can't put a RewriteMap in <Directory>s. Put it in the <VirtualHost> or main server configuration.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap wrote:RewriteMap Directive

Description: Defines a mapping function for key-lookup
Syntax: RewriteMap MapName MapType:MapSource
Context: server config, virtual host
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Wed Sep 09, 2009 11:28 pm

Didn't work with RewriteMap so i made a new script that takes the name/title, finds the associated numeric id then runs the original script.

now i have something like this:

www.my-site.com/user/?u=Falcon

and i need to change that into this:

www.my-site.com/Falcon

I hope that this will be more easy then that RewriteMap ^ ^
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 43 guests

cron