System using mapfiles, how do I apply redirects for old page
20 posts
• Page 1 of 1
System using mapfiles, how do I apply redirects for old page
Hi, the system I work with is using mapfiles, and now I need to redirect old (google indexed) pages. Which rules is it possible to add to the .htaccess?
I wish to redir an old page that has for example the url:
/display.asp?id=32 (old page) to the new page:
/se/my-new-page/
and of course all other pages with the url: /display.asp?id=xx as well ...
Is this possible to accomplish? And in that case, how?
The map-file (default_se.txt) in the new system looks like this
=======================================
home 1
my-new-page 2 <-- this is the "pretty-url" I wish to redirect the old display.asp?id=32 to
This is the .htaccess file, that I wish to modify with the the new rules added
=========================================================
RewriteEngine on
RewriteBase /
## MAP FILE SOLUTION
RewriteMap default_se txt:mfiles/default_se.txt
RewriteMap default_en txt:mfiles/default_en.txt
RewriteMap default_de txt:mfiles/default_de.txt
RewriteMap news_se txt:db/mfiles/news_se.txt
RewriteMap news_en txt:db/mfiles/news_en.txt
RewriteMap news_de txt:db/mfiles/news_de.txt
RewriteMap lower int:tolower
# default
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_de:${lower:%2}}&lng=%1 [NC,L]
# news
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_de:${lower:%2}}&lng=%1 [NC,L]
Kind Regards
/ Anette
I wish to redir an old page that has for example the url:
/display.asp?id=32 (old page) to the new page:
/se/my-new-page/
and of course all other pages with the url: /display.asp?id=xx as well ...
Is this possible to accomplish? And in that case, how?
The map-file (default_se.txt) in the new system looks like this
=======================================
home 1
my-new-page 2 <-- this is the "pretty-url" I wish to redirect the old display.asp?id=32 to
This is the .htaccess file, that I wish to modify with the the new rules added
=========================================================
RewriteEngine on
RewriteBase /
## MAP FILE SOLUTION
RewriteMap default_se txt:mfiles/default_se.txt
RewriteMap default_en txt:mfiles/default_en.txt
RewriteMap default_de txt:mfiles/default_de.txt
RewriteMap news_se txt:db/mfiles/news_se.txt
RewriteMap news_en txt:db/mfiles/news_en.txt
RewriteMap news_de txt:db/mfiles/news_de.txt
RewriteMap lower int:tolower
# default
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${default_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${default_de:${lower:%2}}&lng=%1 [NC,L]
# news
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${news_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${news_de:${lower:%2}}&lng=%1 [NC,L]
Kind Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Hello,
In case you want a redirect rule, than I'd suggest smth like the following:
mapfile would contain:
Regards
Andrew
In case you want a redirect rule, than I'd suggest smth like the following:
- Code: Select all
RewriteMap display_se txt:mfiles/display_se.txt
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}? [NC,R=301,L]
mapfile would contain:
12 new-page
13 other-page
23 something_else
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Hi Andrew, and thank you for taking your time
The rule works ... almost
I implemented the rule in the .htaccess and made a mapfile (display_se)
3 about-us
But where it should display, ex. www.mydomain.com/se/about-us/ <-- slash at the end of the url
it only goes to
www.mydomain.com/se/about-us <-- no slash and thus I get a not-found page.
Kind regards
/ Anette
The rule works ... almost
I implemented the rule in the .htaccess and made a mapfile (display_se)
3 about-us
But where it should display, ex. www.mydomain.com/se/about-us/ <-- slash at the end of the url
it only goes to
www.mydomain.com/se/about-us <-- no slash and thus I get a not-found page.
Kind regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Adjust the rule:
Try using:
instead of:
Regards
Andrew
Try using:
- Code: Select all
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L]
instead of:
- Code: Select all
Rewriterule ^display\.asp$ /se/${display_se:%1}? [NC,R=301,L]
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Sorry, the first rule worked, I made a typo
I.e.
This works
# MAPFILE
RewriteMap display_se txt:mfiles/display_se.txt
# REDIR TEST
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}? [NC,R=301,L]
But I came to think of that I have english and german pages that needs to be redirected,
the url for these are, for example:
/display.asp?id=3&lang=en
I realize that I need seperate mapfiles for these, which is not a problem, but how do I add the second parameter (lang=xx) to the rule?
Kind Regards
/ Anette
I.e.
This works
# MAPFILE
RewriteMap display_se txt:mfiles/display_se.txt
# REDIR TEST
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}? [NC,R=301,L]
But I came to think of that I have english and german pages that needs to be redirected,
the url for these are, for example:
/display.asp?id=3&lang=en
I realize that I need seperate mapfiles for these, which is not a problem, but how do I add the second parameter (lang=xx) to the rule?
Kind Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
How about this one?
Regards
Andrew
- Code: Select all
# MAPFILE
RewriteMap display_se txt:mfiles/display_se.txt
# REDIR TEST
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/$2/${display_se:%1}? [NC,R=301,L]
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Sorry again - the second rule, for the first example (i.e. pages without the parameter lang=xx) is the one that is working, I had added a slash after the page name in the display_se mapfile like:
3 om-oss/
and that's why the first rule you provided didn't work.
This is the working rule:
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L] <-- with the slash before the question mark.
and the mapfile looks like this:
3 om-oss
I will try the rule you provided for the english and german urls and let you know asap
Kind regards
/ Anette
3 om-oss/
and that's why the first rule you provided didn't work.
This is the working rule:
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L] <-- with the slash before the question mark.
and the mapfile looks like this:
3 om-oss
I will try the rule you provided for the english and german urls and let you know asap
Kind regards
/ Anette
Last edited by Anejo on 26 Apr 2012, 09:39, edited 1 time in total.
Re: System using mapfiles, how do I apply redirects for old
Hi Andrew, when using this rule:
RewriteMap display_en txt:mfiles/display_en.txt
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/$2/${display_en:%1}/? [NC,R=301,L] <-- added slash here
The result is:
/en//about-us/ <-- i.e. one slash to many between "en" and "about-us"
The mapfile display_en looks like this:
3 about-us
The mapfile display_se looks like this:
3 om-oss
Could it be a problem that the same id is used in the two mapfiles, even if the parameter behind (lang=xx) retrieves info from different db-tables?
(i.e. tbl_pages_se, and tbl_pages_en) and when the parameter "lang=xx" is omitted, the system retreives from the tbl_pages_se by default.
RewriteMap display_en txt:mfiles/display_en.txt
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/$2/${display_en:%1}/? [NC,R=301,L] <-- added slash here
The result is:
/en//about-us/ <-- i.e. one slash to many between "en" and "about-us"
The mapfile display_en looks like this:
3 about-us
The mapfile display_se looks like this:
3 om-oss
Could it be a problem that the same id is used in the two mapfiles, even if the parameter behind (lang=xx) retrieves info from different db-tables?
(i.e. tbl_pages_se, and tbl_pages_en) and when the parameter "lang=xx" is omitted, the system retreives from the tbl_pages_se by default.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Well,
Two slashes is the result that lang= was empty. Simply make another rule with one parameter having null.
there shouldn't be any problems with two different entries in two different files.
Regards
Andrew
Two slashes is the result that lang= was empty. Simply make another rule with one parameter having null.
there shouldn't be any problems with two different entries in two different files.
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
OK, could it have something to do with that in the old system the querystring parameter is lang=xx and in the new system the qs-parameter is lng=xx?
Regards
/ Anette
Regards
/ Anette
Re: System using mapfiles, how do I apply redirects for old
Hi Andrew, I'm sorry but I can't get the rules for pages with the lang=xx parameter working and I've tried adding a second rule for the case lang-parameter null, but I'm not sure how to write that rule (I've tried several scenarios that didn't work - so I removed the rule again).
I call the pages like this:
/display.asp?id=3&lang=en <-- i.e. the langparameter is not empty
The complete .htaccess looks like this now
==========================
The Mapfiles for the english pages looks like this
Mapfile for the new pages: pages_en.txt
----------------------------------------------
Mapfile for redirect to new pages: display_en.txt
------------------------------------------------------
Regards
/ Anette
I call the pages like this:
/display.asp?id=3&lang=en <-- i.e. the langparameter is not empty
The complete .htaccess looks like this now
==========================
- Code: Select all
RewriteEngine on
RewriteBase /
## OLD SYSTEM MAPFILES
RewriteMap display_se txt:mfiles/display_se.txt
RewriteMap display_en txt:mfiles/display_en.txt
## NEW SYSTEM MAPFILES
RewriteMap pages_se txt:mfiles/pages_se.txt
RewriteMap pages_en txt:mfiles/pages_en.txt
RewriteMap pages_de txt:mfiles/pages_de.txt
RewriteMap calendar_se txt:mfiles/calendar_se.txt
RewriteMap calendar_en txt:mfiles/calendar_en.txt
RewriteMap calendar_de txt:mfiles/calendar_de.txt
RewriteMap lower int:tolower
# NEW SYSTEM - RULES FOR MAPPINGS
# Pages
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_de:${lower:%2}}&lng=%1 [NC,L]
# Calendar
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_en:${lower:%2}}&lng=%1 [NC,L]
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_de:${lower:%2}}&lng=%1 [NC,L]
# OLD SYSTEM - RULES FOR REDIRECTION TO NEW SYSTEM MAPFILES
# SWEDISH <-- This rule works!
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L]
# ENGLISH <--- This rule doesn't work I'ts here I get the /en//about-us/
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/$2/${display_en:%1}/? [NC,R=301,L]
The Mapfiles for the english pages looks like this
Mapfile for the new pages: pages_en.txt
----------------------------------------------
- Code: Select all
3 about-us
5 our-products
6 contact-us
Mapfile for redirect to new pages: display_en.txt
------------------------------------------------------
- Code: Select all
9 about-us
15 our-products
33 contact-us
Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Hello,
of course!!!! It's a mistake - $2, while it should be %2 in the following:
Regards
Andrew
of course!!!! It's a mistake - $2, while it should be %2 in the following:
- Code: Select all
# ENGLISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/$2/${display_en:%1}/? [NC,R=301,L]
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Good morning Andrew (and thank you for your patience)
I changed the rule as follows:
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/%2/${display_en:%1}/? [NC,R=301,L]
and now I get one /en/ to many, like this:
/en/en/about-us/
Regards
/ Anette
I changed the rule as follows:
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /en/%2/${display_en:%1}/? [NC,R=301,L]
and now I get one /en/ to many, like this:
/en/en/about-us/
Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
I gave that rule as a sample, so why don't you use:
Regards
Andrew
- Code: Select all
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_en:%1}/? [NC,R=301,L]
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Hi sorry, I didn't understand, these rules are so tricky to grasp and I thought the /en/ was required for this to work
But the english rule works now, a million thanks Andrew!!!
I also think that there's some cashing or something involved here, because when I test the rules it's like they don't begin to work immediately.
And I think the cashing is on the server as I empty my browser caches on a regular basis, and I also test in several different browsers.
Now I've copied the english rule and modified it for the german pages (id=x&lang=de), I guess I have to be patient and wait for a while to see if
it works or not because right now the display.asp?id=5&lang=de goes to /de/about-us/ <-- instead of /de/uber-uns/ (as of the german mapfile display_de).
Cheers, and once again - I'm so very grateful for your patience and your help!
/ Anette
But the english rule works now, a million thanks Andrew!!!
I also think that there's some cashing or something involved here, because when I test the rules it's like they don't begin to work immediately.
And I think the cashing is on the server as I empty my browser caches on a regular basis, and I also test in several different browsers.
Now I've copied the english rule and modified it for the german pages (id=x&lang=de), I guess I have to be patient and wait for a while to see if
it works or not because right now the display.asp?id=5&lang=de goes to /de/about-us/ <-- instead of /de/uber-uns/ (as of the german mapfile display_de).
Cheers, and once again - I'm so very grateful for your patience and your help!
/ Anette
Re: System using mapfiles, how do I apply redirects for old
Hi Andrew,
I'm beginning to believe that the rules for the new system mapfiles interferes with the redirect rules?
(and the caching had to do with MSIE 9, ctrl+5 clears the cache, I used F5 which simply reloads the page without clearing the cache).
The rule for the german pages works kind of now, but it picks the english title:
/de/membership-info/ instead of /de/uber-uns/ for the redirect url:
/display.asp?id=4&lang=de (i.e. the old url that is to be directed to the new system url)
THE ENGLISH MAPFILE: display_en (for redirecting the old urls)
2 home
3 about-us
4 membership-info
5 preventive-advice
THE ENGLISH MAPFILE: pages_en (for the new system urls)
search 1
home 2
about-us 3
membership-info 4
preventive-advice 5
Please note! It's a coincident that the id:s for the new and old english urls are all the same!
THE GERMAN MAPFILE: display_de (for redirecting the old urls)
2 startseite
3 mitgliedschaft
4 uber-uns
5 ratschlage-fur-ihre-reise
THE GERMAN MAPFILE: pages_de (for the new system urls)
suche 1
startseite 2
uber-uns 3
mitgliedschaft 4
ratschlage-fur-ihre-reise 5
Please note! For the german pages, the old and new id:s are not all the same!
The .htaccess
----------------
RewriteEngine on
RewriteBase /
## REDIRECT MAPPFILES
RewriteMap display_se txt:mfiles/display_se.txt
RewriteMap display_en txt:mfiles/display_en.txt
RewriteMap display_de txt:mfiles/display_de.txt
## NEW SYSTEM MAPFILES
RewriteMap pages_se txt:mfiles/pages_se.txt
RewriteMap pages_en txt:mfiles/pages_en.txt
RewriteMap pages_de txt:mfiles/pages_de.txt
RewriteMap calendar_se txt:mfiles/calendar_se.txt
RewriteMap calendar_en txt:mfiles/calendar_en.txt
RewriteMap calendar_de txt:mfiles/calendar_de.txt
RewriteMap lower int:tolower
# Default pages
# SWEDISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_se:${lower:%2}}&lng=%1 [NC,L]
# ENGLISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_en:${lower:%2}}&lng=%1 [NC,L]
# GERMAN
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_de:${lower:%2}}&lng=%1 [NC,L]
# Calendar pages
# SWEDISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1 [NC,L]
# ENGLISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_en:${lower:%2}}&lng=%1 [NC,L]
# GERMAN
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_de:${lower:%2}}&lng=%1 [NC,L]
# REDIRECT RULES
# SWEDISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L]
# ENGLISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_en:%1}/? [NC,R=301,L]
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
Kind Regards
/ Anette
I'm beginning to believe that the rules for the new system mapfiles interferes with the redirect rules?
(and the caching had to do with MSIE 9, ctrl+5 clears the cache, I used F5 which simply reloads the page without clearing the cache).
The rule for the german pages works kind of now, but it picks the english title:
/de/membership-info/ instead of /de/uber-uns/ for the redirect url:
/display.asp?id=4&lang=de (i.e. the old url that is to be directed to the new system url)
THE ENGLISH MAPFILE: display_en (for redirecting the old urls)
2 home
3 about-us
4 membership-info
5 preventive-advice
THE ENGLISH MAPFILE: pages_en (for the new system urls)
search 1
home 2
about-us 3
membership-info 4
preventive-advice 5
Please note! It's a coincident that the id:s for the new and old english urls are all the same!
THE GERMAN MAPFILE: display_de (for redirecting the old urls)
2 startseite
3 mitgliedschaft
4 uber-uns
5 ratschlage-fur-ihre-reise
THE GERMAN MAPFILE: pages_de (for the new system urls)
suche 1
startseite 2
uber-uns 3
mitgliedschaft 4
ratschlage-fur-ihre-reise 5
Please note! For the german pages, the old and new id:s are not all the same!
The .htaccess
----------------
RewriteEngine on
RewriteBase /
## REDIRECT MAPPFILES
RewriteMap display_se txt:mfiles/display_se.txt
RewriteMap display_en txt:mfiles/display_en.txt
RewriteMap display_de txt:mfiles/display_de.txt
## NEW SYSTEM MAPFILES
RewriteMap pages_se txt:mfiles/pages_se.txt
RewriteMap pages_en txt:mfiles/pages_en.txt
RewriteMap pages_de txt:mfiles/pages_de.txt
RewriteMap calendar_se txt:mfiles/calendar_se.txt
RewriteMap calendar_en txt:mfiles/calendar_en.txt
RewriteMap calendar_de txt:mfiles/calendar_de.txt
RewriteMap lower int:tolower
# Default pages
# SWEDISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_se:${lower:%2}}&lng=%1 [NC,L]
# ENGLISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_en:${lower:%2}}&lng=%1 [NC,L]
# GERMAN
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${pages_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /default.asp?id=${pages_de:${lower:%2}}&lng=%1 [NC,L]
# Calendar pages
# SWEDISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1 [NC,L]
# ENGLISH
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_en:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_en:${lower:%2}}&lng=%1 [NC,L]
# GERMAN
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${calendar_de:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_de:${lower:%2}}&lng=%1 [NC,L]
# REDIRECT RULES
# SWEDISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /se/${display_se:%1}/? [NC,R=301,L]
# ENGLISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_en:%1}/? [NC,R=301,L]
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
Kind Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Well, it's getting a little complicated now. So I suggest making a condition as in following:
So we hardcode this parameter to be german and use ONLY with display_de. Of course, you can adjust it for your situation. It's just a hint.
Regards
Andrew
- Code: Select all
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=[b](de)[/b]$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
So we hardcode this parameter to be german and use ONLY with display_de. Of course, you can adjust it for your situation. It's just a hint.
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Sorry, tried this and it still uses the english mapfile-titles, even if it goes to the german pages
or vice versa... I'll do some more testing though to see if the problem lies elsewhere.
Once again, thank you for your support and your patience
Kind Regards
/ Anette
PS! Just checking, is it correct that I should remove the previous rule for the german pages, and
replace it with the new none you provided, i.e:
This is being removed:
and replaced with:
I have tried every combination without success, i.e. keeping both rules, removing the old rule and replacing it with the new rule.
or vice versa... I'll do some more testing though to see if the problem lies elsewhere.
Once again, thank you for your support and your patience
Kind Regards
/ Anette
PS! Just checking, is it correct that I should remove the previous rule for the german pages, and
replace it with the new none you provided, i.e:
This is being removed:
- Code: Select all
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=([^&]+)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
and replaced with:
- Code: Select all
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=[b](de)[/b]$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
I have tried every combination without success, i.e. keeping both rules, removing the old rule and replacing it with the new rule.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: System using mapfiles, how do I apply redirects for old
Hello,
I hope you understand that and are the formatting of the text in forum to highlight the changed part and you shouldn't paste it in config file.
there're also 2 options: move this rule on top of the English rule, OR apply the same changes to the english rule and insert EN istead of DE.
Regards
Andrew
I hope you understand that and are the formatting of the text in forum to highlight the changed part and you shouldn't paste it in config file.
there're also 2 options: move this rule on top of the English rule, OR apply the same changes to the english rule and insert EN istead of DE.
Regards
Andrew
Re: System using mapfiles, how do I apply redirects for old
Hi Andrew,
Just wanted to report the solution that worked, these rules works perfectly.
For the English pages:
and for the german pages
Than you very much for your help and your patience!
Kind Regards
/ Anette
Just wanted to report the solution that worked, these rules works perfectly.
For the English pages:
- Code: Select all
# ENGLISH
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=(en)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_en:%1}/? [NC,R=301,L]
and for the german pages
- Code: Select all
# GERMAN
RewriteCond %{QUERY_STRING} ^id=([^&]+)&lang=(de)$ [NC]
Rewriterule ^display\.asp$ /%2/${display_de:%1}/? [NC,R=301,L]
Than you very much for your help and your patience!
Kind Regards
/ Anette
20 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests