permanent redirect problem

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

permanent redirect problem

Post by peggylon »

Hi,

after a long time of running my blog without url-rewriting I recently decided to use it, in order to get
rid of the irritating domain.com/?/archives/id-article.html url structure.

I managed to change urls as desired. .htaccess is doing it's job, after I had to change the initial lines slightly.

now:

Code: Select all

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
AddCharset utf-8 .css .html .xhtml
old article url: http://www.multikulinarisch.es/?/archiv ... lerie.html
new article url: http://www.multikulinarisch.es/677-apfelgalerie.html

Then I tried to implement a permanent redirect (301) in order to leave old (often linked to) urls accesible as well as not loose pretty good google-indication on several articles.

I tried all sorts of rewrite rules. (in blog directory's .htaccess as well as in root directory)
A redirect never occured (url in browser didn't change). When checking my old urls in web-sniffer.net it never shows status code 301 but always 200. Therefore the redirect doesn't seem to work at all.

I read through pretty much all redirect posts in this forum and still couldn't figure out, why redirect
is not working in my case.
I'm aware, that php header('Location:...') may be used, but really would like to keep
rewriting/redirecting stuff to .htaccess
Even though canonical url may be used, too, I'd still prefer a proper redirect. Therefore I tried (among other stuff):

1)

Code: Select all

RedirectPermanent \?/archives/ http://www.multikulinarisch.es/
2)

Code: Select all

RewriteRule ^\?/archives/(.*)$ /$1 [R=301]
3)

Code: Select all

RewriteRule ^/\?/archives/(.*)$ /$1 [R=301]
4)

Code: Select all

RewriteRule \?/archives/(.*) /$1 [R=301]
5)

Code: Select all

RewriteRule ^\?/archives/ http://www.multikulinarisch.es/ [R=301]
6)

Code: Select all

RewriteCond %{REQUEST_URI} ^\?
RewriteRule (.*)/archives/(.*)$ /$2 [R=301]
7)

Code: Select all

RewriteCond %{REQUEST_URI} /\?/
RewriteRule /archives/(.*) /$1 [R=301]
8 )

Code: Select all

RewriteCond %{REQUEST_URI} ^\?/
RewriteRule /archives/(.*) /$1 [R=301]
9)

Code: Select all

RewriteCond %{REQUEST_URI} /\?{1}
RewriteRule ^(.*)/archives/(.*)$ /$2 [R=301]
10) commenting out this section, since it creates the /?/... url syntax

Code: Select all

RewriteRule ^((([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) ?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) ?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) ?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) ?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) ?/$1 [NC,L,QSA]
Nothing did the trick.
Could anyone please help me, to achieve a permanent redirect for articles? Thanks,
Peggy
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: permanent redirect problem

Post by garvinhicking »

Hi!

Due to the "?" in the URL you definitely need to work with RewriteCond and the REQUEST_URI strings, and that's a bit tricky.

also you need to make sure to list your custom rewrite rules in s9y BEFORE the s9y custom ones, and make sure to append a [L] to your RewriteRules - else, s9y would still catch old patterns and neglect yorur redirect.

Also, you should not need to modify any of s9y's rewrite rules, they are needed for proper working s9y.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
peggylon
Regular
Posts: 51
Joined: Tue Jul 01, 2008 6:32 pm
Location: Berlin
Contact:

Re: permanent redirect problem

Post by peggylon »

Hi Garvin,

thanks for your speedy reply. I will try more options using RewriteCond and [L].
Are you suggesting php redirect instead? How is everyone else, using mod_rewrite doing permanent redirects?

You are right about leaving s9y rewrite conditions untouched. I restored them already.

Thanks for the great work and support!
----------
peggylon aka multikulinaria http://www.multikulinarisch.es
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: permanent redirect problem

Post by garvinhicking »

Hi!

Ok, let me know what you tried and what might not work.

I meant that you should do .htaccess rewrite, that's the best way to do - but you should always put the rules before the "#Begin s9y" part, so that you do not directly touch any of s9y's RewriteRules.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply