?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 4
Joined: 19 Dec 2012, 13:01

?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

19 Dec 2012, 13:14

good morning, trying to do a 301 permanent redirect from
site.com/buy-dogs.aspx?type=tibetan-mastiff TO site.com/tibetan-mastiff

people clicking site.com/buy-dogs.aspx?type=tibetan-mastiff
should see site.com/tibetan-mastiff in their url bar
with content from site.com/buy-dogs.aspx?type=tibetan-mastiff

since there's only 4 urls, a mapfile.txt won't be necessary

admin, i've tried some examples from this forum but each of them was slightly different from my implementation, so 1:1 copies never worked. i'm out of examples, so could you please help? :oops:

User avatar
Posts: 27
Joined: 04 Dec 2012, 21:06

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

19 Dec 2012, 21:44

Irrelevant!!!

User avatar
Posts: 4
Joined: 19 Dec 2012, 13:01

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

20 Dec 2012, 01:13

go tie your father's shoes if you have nothing better to do

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

20 Dec 2012, 06:36

Hello,

Try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^type=tibetan-mastiff$ [NC]
RewriteRule ^buy-dogs\.aspx$ /tibetan-mastiff? [NC,R=301,L]

RewriteRule ^tibetan-mastiff$ /buy-dogs.aspx?type=tibetan-mastiff [NC,L]


but if you want a universal rule, try:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^type=([^&]+)$ [NC]
RewriteRule ^buy-dogs\.aspx$ /%1? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /buy-dogs.aspx?type=$1 [NC,L]


Regards
Andrew

User avatar
Posts: 4
Joined: 19 Dec 2012, 13:01

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

20 Dec 2012, 08:46

HeliconAndrew wrote:Hello,

Try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^type=tibetan-mastiff$ [NC]
RewriteRule ^buy-dogs\.aspx$ /tibetan-mastiff? [NC,R=301,L]

RewriteRule ^tibetan-mastiff$ /buy-dogs.aspx?type=tibetan-mastiff [NC,L]


but if you want a universal rule, try:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^type=([^&]+)$ [NC]
RewriteRule ^buy-dogs\.aspx$ /%1? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /buy-dogs.aspx?type=$1 [NC,L]


Regards
Andrew


andrew, thank you,
both appear to work!! however, there is now an

The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.


error in firefox. ie just seems to load something and then stop (page won't change)
what could be causing this? looking at http headers in firefox, it appears the 301 goes on and on several times (no page changes in browser) and then halts (upon which i'm shown that error)

please help one more time,

let's hope the children in tibet can be warm soon!!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

21 Dec 2012, 07:36

It's a redirect loop. Which means there's another rule that takes part in it... or there's smh else on your side.

Regards
Andrew

User avatar
Posts: 4
Joined: 19 Dec 2012, 13:01

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

22 Dec 2012, 11:57

andrew, i've narrowed down what seems to happen--

RewriteCond %{QUERY_STRING} ^type=tibetan-mastiff$ [NC]
RewriteRule ^buy-dogs\.aspx$ /tibetan-mastiff? [NC,R=301,L]
RewriteRule ^tibetan-mastiff$ /buy-dogs.aspx?type=tibetan-mastiff [NC,L]

with this one, site.com/buy-dogs.aspx?type=tibetan-mastiff
redirects to site.com/tibetan-mastiff
AND THEN IMMEDIATELY RE-REDIRECTS TO site.com/buy-dogs.aspx?type=tibetan-mastiff
the loop seems to come into existence because the longurl redirects to the shorturl without "stopping" to load the content. they just keep redirecting into eachother

i've tried removing the last line and only going with

RewriteCond %{QUERY_STRING} ^type=tibetan-mastiff$ [NC]
RewriteRule ^buy-dogs\.aspx$ /tibetan-mastiff? [NC,R=301,L]

however, in this case it attempts to look for... a physical directory named /tibetan-mastiff, which obviously doesn't exist on the ftp. the result is a 404 (not found) error

do you have any advice?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: ?301 buy-dogs.aspx?type=tibetan-mastiff HOW?

24 Dec 2012, 04:46

This is very strange, because only one rule has redirect flag - R=301. Please, double check the rules and make sure you use it only i one of the config files.

Regards
Andrew

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 4 guests