Hi everyone,
I have made some changes in my URLs and now want to 301 redirect the old pages to the new ones. I searched around to figure out how exactly to create the 301 rule in the .htaccess file. I tried several syntaxes but neither of them worked and one even crashed the server (500)
Can someone please post a detailed explanation of the 301 redirect rule that works in serendipity (special characters and everything)?
How to implement 301?
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to implement 301?
Hi!
Tell us which ones you tried and we can tell you what's wrong about it
Regards,
Garvin
Tell us which ones you tried and we can tell you what's wrong about it
s9y is nothing different/specific than every .htacces RewriteRule, so you can google it up, there are many tutorials about this...Can someone please post a detailed explanation of the 301 redirect rule that works in serendipity (special characters and everything)?
Regards,
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/
# 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/
I tried which gave me a 500 error
tried the same code with full URLs - nothing.
Tried --still nothing
Tried the same with full second URL -- nothing
Tried with full URLs on both sides -- nothing...
I am either missing something in the code or I just don't write where I have to.
Can you guys tell me what to write in the .htaccess so I can redirect
mysite.com/index.php?/archives/4-old-url.html to mysite.com/archives/new-url.html
Code: Select all
Redirect permanent /index.php?/archives/4-old-url.html /archives/new-url.html
tried the same code with full URLs - nothing.
Tried
Code: Select all
RewriteRule ^/index.php?/archives/old.html /archives/new.html [R] Tried the same with full second URL -- nothing
Tried with full URLs on both sides -- nothing...
I am either missing something in the code or I just don't write where I have to.
Can you guys tell me what to write in the .htaccess so I can redirect
mysite.com/index.php?/archives/4-old-url.html to mysite.com/archives/new-url.html
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
The first one I have not seen yet, I don't think this is a valid mod_rewrit eRule.
The second one is better, but URLs are matched by everything BEFORE the "?", and "?" is a special character in regular expressions.
Maybe you can try (according to http://fantomaster.com/faarticles/rewritingurls.txt which you can read through)
HTH,
Garvin
The first one I have not seen yet, I don't think this is a valid mod_rewrit eRule.
The second one is better, but URLs are matched by everything BEFORE the "?", and "?" is a special character in regular expressions.
Maybe you can try (according to http://fantomaster.com/faarticles/rewritingurls.txt which you can read through)
Code: Select all
RewriteCond %{QUERY_STRING} ^/archives/old.html$
RewriteRule ^.* /archives/new.html [R]
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/
# 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/
Ok, so I added
and it DID redirect it to the new URL, but added " ?url=/archive " at the end of the new address. Any ideas how to remove it?
Also, for some reason in could not redirect /index.php?/archives/old-url.html to the new one, and I am pretty sure it has to do with that "?" in the middle.
Code: Select all
Redirect 301 /archives/old-url.html http://mysite.com/archives/new-url.htmlAlso, for some reason in could not redirect /index.php?/archives/old-url.html to the new one, and I am pretty sure it has to do with that "?" in the middle.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Yeah, because of that "?" you need to use RewriteCOND and not only RewriteRule...
HTH,
Garvin
Yeah, because of that "?" you need to use RewriteCOND and not only RewriteRule...
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/
# 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/
I tried everything and the only rule that seems to be working is the Redirect 301 from my previous post, but it only works for URLs without the " index.php?" (URLs which are already rewritten with the functions_permalinks.inc.php file)
I am thinking that somewhere on the road there is something that overrides all the additional RewriteRules I enter and the only thing working is the Redirect 301 rule, but I can't find what it is.
Here is an exact copy of the .htaccess file
Do you find anything out of the ordinary (the only change I have made is commenting out one of the lines, as I use the /admin.php for somehing else)
I am thinking that somewhere on the road there is something that overrides all the additional RewriteRules I enter and the only thing working is the Redirect 301 rule, but I can't find what it is.
Here is an exact copy of the .htaccess file
Code: Select all
# BEGIN s9y
ErrorDocument 404 /index.php
DirectoryIndex /index.php
php_value session.use_trans_sid 0
php_value register_globals off
RewriteEngine On
RewriteBase /
RewriteRule ^((archives/[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
#RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive/? index.php?url=/archive [L,QSA]
RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]
<Files *.tpl.php>
deny from all
</Files>
<Files *.tpl>
deny from all
</Files>
<Files *.sql>
deny from all
</Files>
<Files *.inc.php>
deny from all
</Files>
<Files *.db>
deny from all
</Files>
# END s9y-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
You should definitely put your custom rewriteRules as the first ones. Try to append [L] to its option so that htaccess stops parsing when your own rule is matched.
Regards,
Garvin
You should definitely put your custom rewriteRules as the first ones. Try to append [L] to its option so that htaccess stops parsing when your own rule is matched.
Regards,
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/
# 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/