Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
help with a RewriteRule
Hi,
I’m trying to rewrite an old subfolder to a new one:
So, I’ve tried the following rewrite rule (taken from the examples on stupid htaccess tricks):
RewriteRule ^(.*)/vintage-collection/(.*)$ $1/vintage/$2 [L,R=301]
But the rewritten url looks like this:
http://www.domain.com/home/user/domains/domain.com/html/electric-guitars/vintage/62-fender-jazzmaster
The server path to the folder is being appended to the rewritten url :(
I’ve tried setting the RewriteBase to that folder path, but no luck.
Thanks.
Offline
#2 2008-11-07 18:39:23
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: help with a RewriteRule
If it’s only a matter of redirecting from one subfolder to another, wouldn’t this be enough?
Redirect permanent /vintage-collection http://site.com/vintage
Offline
Re: help with a RewriteRule
Hi Els,
I’m using gbp_permanent_link, so the chunk of the URL that I want to rewrite corresponds to a “subfolder” (a category, a “subsection”).
The URL is:
http://www.domain.com/section/category/title
I just want to rewrite the “category” chunk.
Offline
#4 2008-11-07 19:11:02
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: help with a RewriteRule
Ah I see. Can’t help you then, I’m not good with regular expressions :( But wouldn’t gbp_permanent_links be able to do that?
Offline
Re: help with a RewriteRule
Thanks anyway, Els. I’m not good with regex either, although I’ve had a regex class this week on a Python course I’m taking.
But you are right… maybe it can be done directly from gbp_permanent_link.
In the meanwhile, if someone out there knows the answer… keep posting :D
Offline
Re: help with a RewriteRule
Wouldn’t this work?
RewriteRule ^/(.*)/vintage-collection/(.*)$ http://site.com/$1/vintage/$2 [L,R=301]
Offline
Re: help with a RewriteRule
That didn’t work either.
In this case, no rewrite at all is being done. The URL stays the same and I must admit that I’m now confused about how this works.
Thanks anyway, ruud.
Offline
Re: help with a RewriteRule
I’m kind of clueless when it comes to this stuff, but what about…
RedirectMatch 301 /section/cat-old(.*) http://domain.tld/section/cat-new$1
Ed. oops, added wildcard.
Last edited by Destry (2008-11-08 23:14:14)
Offline
Re: help with a RewriteRule
Thanks, Destry.
That worked like a charm. :D
This are the two rules I used finally:
RedirectMatch 301 /(.*)/vintage-collection/(.*) http://www.domain.com/$1/vintage/$2
RedirectMatch 301 /(.*)/collection/(.*) http://www.domain.com/$1/$2
Offline
Pages: 1