Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
htaccess sitewide - redirect 301
We are thinking of moving the neme site currently in a’ subdirectory called main to the root.
Does anybody know an htaccess way where we can redirect all incoming traffic to the new urls.
The schema we are using is
www.domain.tld/main/article_id/title
and we wish to redirect it to
www.domain.tld/article_id/title
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: htaccess sitewide - redirect 301
Hi Yiannis
Could you try one of this two, on the .htaccess inside /main/ folder.
Redirect 301 /main/?(.*) /$1
In some servers, you will need to explicitly use the full URL on the destination, so the above would be:
Redirect 301 /main/?(.*) http://www.domain.com/$1
Or:
RewriteRule main/?(.*) $1 [R=301,L]
Hope that works!
Offline
Re: htaccess sitewide - redirect 301
Hi Julián,
There is a way! great! Thanks!
I will be uploading the new site by the end of the week and test your suggestions. I just wasn’t sure that there was a generic way so we couldn’t decide to get rid of the subfolder which through time became superfluous.
I’ll let you know here once the site is up.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: htaccess sitewide - redirect 301
Hint: Apache rewrite guide (not being an .htaccess expert at all)
deleted
Last edited by merz1 (2011-02-07 18:33:09)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: htaccess sitewide - redirect 301
Hi Julián,
There is a way! great! Thanks!
You are welcome.
BTW, there is no need to put the .htaccess in the /main/ folder, I don’t know why I suggested that. Of course, it would work there too, afaik.
Offline
Re: htaccess sitewide - redirect 301
Hi Julián
Just to let you know that Redirect 301 /main/?(.*) http://www.domain.org/$1
seems to be working beautifully.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: htaccess sitewide - redirect 301
Hi Yiannis,
great to know. I’ve tested it in neme.org and saw it works for permalinks, but no for /main/
or /main/some_section/
.
Any ideas?
Offline
Re: htaccess sitewide - redirect 301
Hi Julián, You are right!
added
RewriteEngine On
RewriteRule ^main/texts/ /texts/ [R=301,L]
RewriteRule ^main/arts_info/ /arts_info/ [R=301,L]
RewriteRule ^main/calls/ /calls/ [R=301,L]
Our texts db is very precious to us as it is linked by various universities.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: htaccess sitewide - redirect 301
Just for info, you should be able to combine your three rules into one:
RewriteRule ^main/(texts|arts_info|calls)/ /$1/ [R=301,L]
TXP Builders – finely-crafted code, design and txp
Offline
Re: htaccess sitewide - redirect 301
jakob wrote:
Just for info, you should be able to combine your three rules into one:
RewriteRule ^main/(texts|arts_info|calls)/ /$1/ [R=301,L]
This looked interesting! Tried
RewriteRule ^main/(texts|arts_info|calls|rss|?rss=1|atom|?atom=1)/ /$1/ [R=301,L]
but returns a 500 error
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: htaccess sitewide - redirect 301
Yiannis.
I don’t think you can test for query strings directly on the RewriteRule pattern. You will have to use a RewriteCond %{QUERY_STRING}
to test for a query string.
Anyway, I think this is a One Redirect rule to rule them All:
RedirectMatch 301 ^/main/?(.+)$ http://www.neme.org/$1
I think you could replace all the other lines just with that line. Would like to know…
Offline
Re: htaccess sitewide - redirect 301
maniqui wrote:
Yiannis.
I don’t think you can test for query strings directly on the RewriteRule pattern. You will have to use aRewriteCond %{QUERY_STRING}
to test for a query string.Anyway, I think this is a One Redirect rule to rule them All:
RedirectMatch 301 ^/main/?(.+)$ http://www.neme.org/$1
I think you could replace all the other lines just with that line. Would like to know…
indeed! this is the holy grail of redirects!
Thanks sooo much Julián
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline