Forum Moderators: phranque

Message Too Old, No Replies

rewritemap newbie question

         

webstyler

2:07 pm on Aug 6, 2009 (gmt 0)

10+ Year Member



Hi

I have 3 real page :
a.html
b.html
c.html

I need to make this:
when user call a.html OR aa.html OR aaa.html I need to open always page a.html
when user call b.html OR bb.html OR bbb.html I need to open always page b.html
when user call c.html OR cc.html OR ccc.html I need to open always page c.html

--

I can make all rules on .htaccess as

RewriteEngine on
RewriteRule aa.html a.html?o=aa
RewriteRule aaa.html a.html?o=aaa

But would like to try rewritemap for this, think better as solutions

Any example to rewritemap applicated on this ?

Thanks

g1smd

2:47 pm on Aug 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could possibly do this in two lines of Mod_Rewrite code if the relationship is simple.

However, the fundamental question: do you want a redirect or a rewrite here?

webstyler

2:50 pm on Aug 6, 2009 (gmt 0)

10+ Year Member



This is an example, name is not so simple :) and there are more page

I need to rewrite, customer must see alway name called and not name of real page

webstyler

7:05 am on Aug 8, 2009 (gmt 0)

10+ Year Member



I have already check documentation but have not understand right usage of rewritemap :(

any suggest for it applicated on my base example ?

Thanks

Caterham

11:06 am on Aug 8, 2009 (gmt 0)

10+ Year Member



right usage of rewritemap
But you do have access to the httpd.conf to define one?

webstyler

12:37 pm on Aug 8, 2009 (gmt 0)

10+ Year Member



yes, I have access to httpd.conf :)

Caterham

8:38 pm on Aug 8, 2009 (gmt 0)

10+ Year Member



So a basic txt file (the map file) looks like

value_to_check replacement

like


aa a
aaa a
bb b
bbb b

And the cirectives in your httpd.conf could look like

RewriteEngine on
# defining a map called 'lookup'
RewriteMap lookup txt:/var/www/maps/map.txt
#
# (2) look-up the map with the value stored in $1
RewriteCond ${lookup:$1} ^(.+)
# (1) get aa from r->uri /aa.html and store it in $1 ; (3) substitute with the map-result (if there was one)
RewriteRule ^/([^/.]+)\.html$ /%1.html [L]

webstyler

6:33 am on Aug 10, 2009 (gmt 0)

10+ Year Member



:D

I try immediately

Thanks