redirect not working
30 posts
• Page 1 of 2 • 1, 2
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
redirect not working
Hi,
am quite new to isapi rewrite and any kind of url rewrite. I set up a small test file but only the rewrite part of it (last line) works. The redirect does not work. Here my code:
for better understanding, incoming url from linking pages:
http://www.pet-needs.de/index.asp?m__id=2&ani=1&pag=1
should be redirected to:
http://www.pet-needs.de/royal-canin/katzen/1
The only variable that would change for the redirect is pag=, all the others (m__id, ani) remain the same all the time.
Can anyone help me get this working?
Thanks,
Pascal
ps: strange enough, hours later even the working part does not work anymore...
am quite new to isapi rewrite and any kind of url rewrite. I set up a small test file but only the rewrite part of it (last line) works. The redirect does not work. Here my code:
- Code: Select all
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.89
#enabling rewrite.log
#RewriteLogLevel 9
#enabling error.log
#LogLevel debug
RewriteEngine on
#RewriteBase /
RewriteCond Host: www\.pet-needs\.de
RewriteRule ^([^./]+)\.asp?m__id=2&ani=1&pag=(.*) royal-canin/katzen/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^royal-canin/katzen/(.*)$ index.asp?m__id=2&ani=1&pag=$1 [L]
for better understanding, incoming url from linking pages:
http://www.pet-needs.de/index.asp?m__id=2&ani=1&pag=1
should be redirected to:
http://www.pet-needs.de/royal-canin/katzen/1
The only variable that would change for the redirect is pag=, all the others (m__id, ani) remain the same all the time.
Can anyone help me get this working?
Thanks,
Pascal
ps: strange enough, hours later even the working part does not work anymore...
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
Hi,
Would it maybe be possible that someone from Helicon would have a look at it with remote access? If I get this to work in the way I want for this one site, then I would need a full license because I have about 5 different sites each with a few houndreds of redirects. I tried ape first, but here the rewrites don't even fire (no logging in the files even at lvl 9).
Would it maybe be possible that someone from Helicon would have a look at it with remote access? If I get this to work in the way I want for this one site, then I would need a full license because I have about 5 different sites each with a few houndreds of redirects. I tried ape first, but here the rewrites don't even fire (no logging in the files even at lvl 9).
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Hello,
The correct syntax would be:
Sure, we provide online assistance and can do everything for you under the terms of Premium Support Plan, see here
The correct syntax would be:
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=2&ani=1&pag=(.*)$ [NC]
RewriteRule ^([^./]+)\.asp$ royal-canin/katzen/%1? [NC,R=301,L]
Sure, we provide online assistance and can do everything for you under the terms of Premium Support Plan, see here
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
still not working. I get a 404 every time when using the pretty url directly and the rewrite does not take place (url remains the ugly one).
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
Here it is:
1 test for both new and old url. The new url generates a 404, the other just loads and doesn't change to pretty url.
Regards,
Pascal
- Code: Select all
(2) init rewrite engine with requested uri /royal-canin/katzen/1
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri '/royal-canin/katzen/1'
(3) applying pattern '^([^./]+)\.asp$' to uri '/royal-canin/katzen/1'
(2) init rewrite engine with requested uri /bildklein/royal_canin_kitten_main_coon.jpg
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri '/bildklein/royal_canin_kitten_main_coon.jpg'
(3) applying pattern '^([^./]+)\.asp$' to uri '/bildklein/royal_canin_kitten_main_coon.jpg'
(2) init rewrite engine with requested uri /index.asp?m__id=2&ani=1&pag=1
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri '/index.asp'
(3) applying pattern '^([^./]+)\.asp$' to uri '/index.asp'
(2) init rewrite engine with requested uri /bildklein/royal_canin_kitten_main_coon.jpg
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri '/bildklein/royal_canin_kitten_main_coon.jpg'
(3) applying pattern '^([^./]+)\.asp$' to uri '/bildklein/royal_canin_kitten_main_coon.jpg'
1 test for both new and old url. The new url generates a 404, the other just loads and doesn't change to pretty url.
Regards,
Pascal
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Simple. Uncomment "#RewriteBase /" )))
Regards
Andrew
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
Great Andrew. Thx. That makes the redirect work but I still have the problem with the 404 error showing up with the rewritten pretty url...
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Well according to your log there's no such pattern as has been provided: ^royal-canin/katzen/(.*)$.
This means you don't have that rule in config file, or it hasn't been read, etc.
If not, please, provide both rule and the rewrite.log for testing request.
Regards
Andrew
(2) init rewrite engine with requested uri /royal-canin/katzen/1
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri '/royal-canin/katzen/1'
(3) applying pattern '^([^./]+)\.asp$' to uri '/royal-canin/katzen/1'
This means you don't have that rule in config file, or it hasn't been read, etc.
If not, please, provide both rule and the rewrite.log for testing request.
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
ok, now I got that part working too. But if I want to add another rule it's not working correctly as it does not add the last variable (the number at the end for the page)
I tried this:
and this:
to no avail.
it always changes to pet-needs.de/royal-canin/hunde/
the 1st rule fires correctly to pet-needs.de/royal-canin/katzen/1 (or whatever number it needs)
the correct page is shown when entering the pretty url directly as adding the following line right befind the 1st one works.
RewriteRule ^royal-canin/hunde/(.*)$ index.asp?m__id=2&ani=2&pag=$1 [L]
Regards,
Pascal
I tried this:
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=2&ani=1&pag=(.*)$ [NC]
RewriteRule ^([^./]+)\.asp$ royal-canin/katzen/%1? [NC,R=301,L]
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=2&ani=2&pag=(.*)$ [NC]
RewriteRule ^([^./]+)\.asp$ royal-canin/hunde/%1? [NC,R=301,L]
and this:
- Code: Select all
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=2&ani=1&pag=(.*)$ [NC]
RewriteRule ^([^./]+)\.asp$ royal-canin/katzen/%1? [NC,R=301,L]
RewriteCond %{QUERY_STRING} ^m__id=2&ani=2&pag=(.*)$ [NC]
RewriteRule ^([^./]+)\.asp$ royal-canin/hunde/%1? [NC,R=301,L]
to no avail.
it always changes to pet-needs.de/royal-canin/hunde/
the 1st rule fires correctly to pet-needs.de/royal-canin/katzen/1 (or whatever number it needs)
the correct page is shown when entering the pretty url directly as adding the following line right befind the 1st one works.
RewriteRule ^royal-canin/hunde/(.*)$ index.asp?m__id=2&ani=2&pag=$1 [L]
Regards,
Pascal
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Can't say anything without rewrite.log for testing request.
Regards
Andrew
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
Here it comes:
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/hunde/'
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'royal-canin/hunde/'
(1) Rewrite URL to >> /index.asp?m__id=2&ani=2&pag=
(2) rewrite 'royal-canin/hunde/' -> '/index.asp?m__id=2&ani=2&pag='
(2) internal redirect with /index.asp?m__id=2&ani=2&pag= [INTERNAL REDIRECT]
(2) init rewrite engine with requested uri /bildklein/royal_canin_kitten_main_coon.jpg
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'bildklein/royal_canin_kitten_main_coon.jpg'
(3) applying pattern '^([^./]+)\.asp$' to uri 'bildklein/royal_canin_kitten_main_coon.jpg'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'bildklein/royal_canin_kitten_main_coon.jpg'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'bildklein/royal_canin_kitten_main_coon.jpg'
(2) init rewrite engine with requested uri /royal-canin/katzen/1
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/katzen/1'
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/katzen/1'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'royal-canin/katzen/1'
(4) RewriteCond: input='\\?\D:\var\www\root_zotto\pet-needs.de\wwwroot\royal-canin\katzen\1' pattern='!-f' => matched
(4) RewriteCond: input='\\?\D:\var\www\root_zotto\pet-needs.de\wwwroot\royal-canin\katzen\1' pattern='!-d' => matched
(1) Rewrite URL to >> /index.asp?m__id=2&ani=1&pag=1
(2) rewrite 'royal-canin/katzen/1' -> '/index.asp?m__id=2&ani=1&pag=1'
(2) internal redirect with /index.asp?m__id=2&ani=1&pag=1 [INTERNAL REDIRECT]
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Well,
I edited your log to make it more readable.
Unfortunately, there wasn't any request to /index.asp?m__id=2&ani=2&pag=XXXX.
Regards
Andrew
I edited your log to make it more readable.
Unfortunately, there wasn't any request to /index.asp?m__id=2&ani=2&pag=XXXX.
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
Well in fact they are included, else it would not be doing lines 1-8...
I treid another time and always get this: (the url tried by entering directly or via link: www.pet-needs.de/index.asp?m__id=2&ani=2&pag=1
I treid another time and always get this: (the url tried by entering directly or via link: www.pet-needs.de/index.asp?m__id=2&ani=2&pag=1
- Code: Select all
(2) init rewrite engine with requested uri /platform/sdl/discovery.svc
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'platform/sdl/discovery.svc'
(2) init rewrite engine with requested uri /royal-canin/hunde/
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'royal-canin/hunde/'
(1) Rewrite URL to >> /index.asp?m__id=2&ani=2&pag=
(2) rewrite 'royal-canin/hunde/' -> '/index.asp?m__id=2&ani=2&pag='
(2) internal redirect with /index.asp?m__id=2&ani=2&pag= [INTERNAL REDIRECT]
(2) init rewrite engine with requested uri /platform/sdl/discovery.svc
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'platform/sdl/discovery.svc'
(2) init rewrite engine with requested uri /platform/sdl/discovery.svc
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'platform/sdl/discovery.svc'
(2) init rewrite engine with requested uri /platform/sdl/discovery.svc
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'platform/sdl/discovery.svc'
(2) init rewrite engine with requested uri /royal-canin/hunde/
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'royal-canin/hunde/'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'royal-canin/hunde/'
(1) Rewrite URL to >> /index.asp?m__id=2&ani=2&pag=
(2) rewrite 'royal-canin/hunde/' -> '/index.asp?m__id=2&ani=2&pag='
(2) internal redirect with /index.asp?m__id=2&ani=2&pag= [INTERNAL REDIRECT]
(2) init rewrite engine with requested uri /
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri ''
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri ''
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri ''
(2) init rewrite engine with requested uri /index.asp
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'index.asp'
(4) RewriteCond: input='www.pet-needs.de' pattern='^www\.pet-needs\.de$' => matched
(4) RewriteCond: input='' pattern='^m__id=2&ani=1&pag=(.*)$' => not-matched
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'index.asp'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'index.asp'
(2) init rewrite engine with requested uri /platform/sdl/discovery.svc
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'platform/sdl/discovery.svc'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'platform/sdl/discovery.svc'
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Well, again... seems like there's no rule for m__id=2&ani=2&pag=(.*), there's only m__id=2&ani=1&pag=(.*) that has been checked:
You see, condition with host has been matched and condition for hunde querystring is omitted.
I suspect you need to follow this documentation to set necessary permissions for .htaccess file - permissions
regards
Andrew
(2) init rewrite engine with requested uri /index.asp
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^([^./]+)\.asp$' to uri 'index.asp'
(4) RewriteCond: input='www.pet-needs.de' pattern='^www\.pet-needs\.de$' => matched
(4) RewriteCond: input='' pattern='^m__id=2&ani=1&pag=(.*)$' => not-matched
(3) applying pattern '^royal-canin/katzen/(.*)$' to uri 'index.asp'
(3) applying pattern '^royal-canin/hunde/(.*)$' to uri 'index.asp'
You see, condition with host has been matched and condition for hunde querystring is omitted.
I suspect you need to follow this documentation to set necessary permissions for .htaccess file - permissions
regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
got it working:
the problem was this part:
when changing it to:
it works like a charm.
but one more question: I know there is chaining but it is interupted as soon as 1 rule is null.
but is it still possible to optimize such redirects for returning parts of strings?
what I mean:
ani=1 is always katzen
ani=2 is always hunde
ani=3 is always frettchen
aso
same for:
m__id=2 always royal-canin
m__id=3 always other-brand
aso
so would it be possible to "chain" these queries like:
checking for m__id first, if we find a match then go for ani and at the end set up the rule for rewriting with the found matches?
so in fact it would be like defining what the various variables would be first.
the problem was this part:
- Code: Select all
RewriteRule ^([^./]+)\.asp$ royal-canin/katzen/%1? [NC,R=301,L]
RewriteRule ^([^./]+)\.asp$ royal-canin/hunde/%1? [NC,R=301,L]
when changing it to:
- Code: Select all
RewriteRule ^index\.asp$ royal-canin/katzen/%1? [NC,R=301,L]
RewriteRule ^index\.asp$ royal-canin/hunde/%1? [NC,R=301,L]
it works like a charm.
but one more question: I know there is chaining but it is interupted as soon as 1 rule is null.
but is it still possible to optimize such redirects for returning parts of strings?
what I mean:
ani=1 is always katzen
ani=2 is always hunde
ani=3 is always frettchen
aso
same for:
m__id=2 always royal-canin
m__id=3 always other-brand
aso
so would it be possible to "chain" these queries like:
checking for m__id first, if we find a match then go for ani and at the end set up the rule for rewriting with the found matches?
so in fact it would be like defining what the various variables would be first.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
Shoot! I must have noticed it before.
Do you mean that you'd like to set each variable one by one, depending on the value?
It'd be smth like this, using the mapfiles, see "Comprehensive mapfiles" in FAQ
NOTE this is just an example to show a possible variant.
Each mapfile would contain numeric ID and the resulting name of the page.
Regards
Andrew
Do you mean that you'd like to set each variable one by one, depending on the value?
It'd be smth like this, using the mapfiles, see "Comprehensive mapfiles" in FAQ
- Code: Select all
RewriteMap ASP_PAGE_mapfile txt:mapfile1.txt
RewriteMap ANImapfile txt:mapfile2.txt
RewriteMap PAQmapfile txt:mapfile3.txt
RewriteCond %{HTTP:Host} ^www\.pet-needs\.de$ [NC]
RewriteCond %{QUERY_STRING} ^m__id=([^&]*)&ani=([^&]*)&pag=.*$ [NC]
RewriteRule ^([^./]+)\.asp$ /${ASP_PAGE_mapfile:$1}/${ANImapfile:%1}/${PAQmapfile:%2}? [NC,R=301,L]
NOTE this is just an example to show a possible variant.
Each mapfile would contain numeric ID and the resulting name of the page.
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
in which folder do I have to create these mapfiles? same as httpd.conf?
Page cannot be found: ulr looks like this: http://www.pet-needs.de/%24%7bmapmid:%7 ... apani:%7d/
Page cannot be found: ulr looks like this: http://www.pet-needs.de/%24%7bmapmid:%7 ... apani:%7d/
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: redirect not working
the map files are supposed to be in the same folder as the rules. If rules are in httpd.conf, than - beside the conf, if it's .htaccess - beside .htaccess.
The link provided is not the one you need to request. You need to request index.asp?m__id=XX&ani=YYY&pag=ZZZ and it should redirect to the correct URL. There's no need to request /${ASP_PAGE_mapfile:$1}/${ANImapfile:%1}/${PAQmapfile:%2}.
In case redirect doesn't happen, please, provide rewrite.log for the testing request.
Logging issues described in FAQ
Regards
Andrew
The link provided is not the one you need to request. You need to request index.asp?m__id=XX&ani=YYY&pag=ZZZ and it should redirect to the correct URL. There's no need to request /${ASP_PAGE_mapfile:$1}/${ANImapfile:%1}/${PAQmapfile:%2}.
In case redirect doesn't happen, please, provide rewrite.log for the testing request.
Logging issues described in FAQ
Regards
Andrew
- Translating-IT
- Posts: 32
- Joined: 14 Apr 2012, 07:28
Re: redirect not working
I know, the url given is the rewritten one, not the one i'm entering.
- Code: Select all
(2) init rewrite engine with requested uri /index.asp?m__id=2&ani=2&pag=1
(1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(3) applying pattern '^index\.asp$' to uri 'index.asp'
(4) RewriteCond: input='www.pet-needs.de' pattern='^www\.pet-needs\.de$' => matched
(4) RewriteCond: input='/index.asp' pattern='^/index\.asp$' => matched
(4) RewriteCond: input='m__id=2&ani=2&pag=1' pattern='^m__id=2&ani=([^&]*)&pag=1' => matched
(1) escaping /royal-canin/${mapani:}/1
(2) explicitly forcing redirect with http://www.pet-needs.de/royal-canin/%24%7bmapani:%7d/1
(2) internal redirect with /index.asp?m__id=2&ani=2&pag=1 [INTERNAL REDIRECT]
30 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 0 guests