This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: redirecting with map and add extension
Author
Message |
gpcsystems
Newbie


Joined: 08 December 2008
Location: Netherlands
Posts: 11
Posted: 12 March 2012 at 10:07am

I have the file below

RewriteEngine on

#static rewrites
RewriteRule ^rouwcentrum-rouwenhorst/historie$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/historie/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/alle-overtuigingen$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/alle-overtuigingen/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/24-uur-per-dag-bereikbaar$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/24-uur-per-dag-bereikbaar/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/ons-rouwcentrum$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/ons-rouwcentrum/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/onze-mensen$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/onze-mensen/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/keurmerken-van-kwaliteit$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/keurmerken-van-kwaliteit/ [NC,U,L,R]
RewriteRule ^overzicht-dienstverlening$ http://www.rouwcentrum-rouwenhorst.nl/onze-diensten/ [NC,U,L,R]
RewriteRule ^algemene-informatie/verzekeringen$ http://www.rouwcentrum-rouwenhorst.nl/uitvaartverzekeringen/ [NC,U,L,R]
RewriteRule ^home$ http://www.rouwcentrum-rouwenhorst.nl/ [NC,U,L,R]

#plaats trailing /
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

RewriteCond %{REQUEST_URI} ^/(?:images|cms) [NC]
RewriteRule .? - [L]

RewriteMap mapfile txt:images/mapfile.txt

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+)/?$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+/[^/]+)/?$ index.asp?${mapfile:$1} [NC,L,QSA]

Now the rule RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L] adds en trailing slah to every redirect. This is the behavior i want. The URL�s will go 3 levels deep. Only in de last level i want to add .html as extension BUT the rewrite in the map must be respected. so:

http://www.domein.nl/about-us/
http://www.domein.nl/about-us/contact.html

The mapfile contains:

about-us submenu=4&show=61
about-us/contact submenu=4&show=64

How can i archieve this?

Back to Top Visit gpcsystems's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 12 March 2012 at 11:17am

Let's try to fix it like this:

RewriteEngine on

RewriteMap mapfile txt:images/mapfile.txt

RewriteCond %{REQUEST_URI} ^/(?:images|cms) [NC]
RewriteRule .? - [L]

#static rewrites
RewriteRule ^rouwcentrum-rouwenhorst/historie$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/historie/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/alle-overtuigingen$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/alle-overtuigingen/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/24-uur-per-dag-bereikbaar$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/24-uur-per-dag-bereikbaar/
[NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/ons-rouwcentrum$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/ons-rouwcentrum/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/onze-mensen$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/onze-mensen/ [NC,U,L,R]
RewriteRule ^rouwcentrum-rouwenhorst/keurmerken-van-kwaliteit$ http://www.rouwcentrum-rouwenhorst.nl/over-ons/keurmerken-van-kwaliteit/
[NC,U,L,R]
RewriteRule ^overzicht-dienstverlening$ http://www.rouwcentrum-rouwenhorst.nl/onze-diensten/ [NC,U,L,R]
RewriteRule ^algemene-informatie/verzekeringen$ http://www.rouwcentrum-rouwenhorst.nl/uitvaartverzekeringen/ [NC,U,L,R]
RewriteRule ^home$ http://www.rouwcentrum-rouwenhorst.nl/ [NC,U,L,R]

#plaats trailing /
RewriteCond %{REQUEST_URI} ^/.*/.*
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

RewriteRule ^([^/.?]+[^.?/])$ $1.html [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)\.html$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+)/$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+/[^/]+)/$ index.asp?${mapfile:$1} [NC,L,QSA]

Hope I understood you correctly.

__________________
Regards,
Anton
Back to Top
 
gpcsystems
Newbie


Joined: 08 December 2008
Location: Netherlands
Posts: 11
Posted: 12 March 2012 at 11:38am

This is indeed working, although it is swapped now.

I get

http://www.domein.nl/about-us.html
http://www.domein.nl/about-us/contact/

in steds of

http://www.domein.nl/about-us/
http://www.domein.nl/about-us/contact.html

Back to Top Visit gpcsystems's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 13 March 2012 at 3:13am

Then I guess I've misunderstood something...

What should be appended to first level folders and what to other (deeper level) ones?
Please provide pairs: initial URL -> resulting URL

__________________
Regards,
Anton
Back to Top
 
gpcsystems
Newbie


Joined: 08 December 2008
Location: Netherlands
Posts: 11
Posted: 13 March 2012 at 3:26am

The only thing i need to archieve is that if the match isn't found in de mapfile the site must return a 404. How can i do that?

It is working now with

RewriteCond %{REQUEST_URI} ^/.*/.*
RewriteRule ^([^.?]+[^.?/])$ $1.html [R,L]

RewriteRule ^([^/.?]+[^.?/])$ $1/ [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+)\.html$ index.asp?${mapfile:$1} [NC,L,QSA]

The result wat i want is

http://www.domein.nl/about-us/
http://www.domein.nl/about-us/contact.html

actually there are 2 levels deep.

Back to Top Visit gpcsystems's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 13 March 2012 at 3:56am

Please try it the following way

RewriteCond %{REQUEST_URI} ^/.*/.*
RewriteRule ^([^.?]+[^.?/])$ $1.html [R,L]

RewriteRule ^([^/.?]+[^.?/])$ $1/ [R,L]

RewriteCond ${mapfile:$1|NOT_FOUND} NOT_FOUND
RewriteRule ^([^/]+)/$ 404.asp [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.asp?${mapfile:$1} [NC,L,QSA]

RewriteCond ${mapfile:$1|NOT_FOUND} NOT_FOUND
RewriteRule ^([^/]+/[^/]+)\.html$ 404.asp [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+/[^/]+)\.html$ index.asp?${mapfile:$1} [NC,L,QSA]

And report the results.

__________________
Regards,
Anton
Back to Top
 
gpcsystems
Newbie


Joined: 08 December 2008
Location: Netherlands
Posts: 11
Posted: 13 March 2012 at 4:04am

Works like a charm!

 

Thanks

Back to Top Visit gpcsystems's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version