Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-03-11 15:05:24

maratnugmanov
Member
From: Russia / Kazakhstan
Registered: 2013-02-24
Posts: 54
Website

My www redirect rule in .htaccess is disappeared?! [noob questions]

I have generic textpattern .htaccess with following text:

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

# SVG
AddType image/svg+xml svg svgz
AddEncoding gzip svgz

I’ve added a new rule yesterday:

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/

inserting new rule here
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
new rule end

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

# SVG
AddType image/svg+xml svg svgz
AddEncoding gzip svgz

But today my .htaccess is right back to default. It could be my mistake – i’ve reinstalled Textpattern a couple of times, so I could forget about .htaccess easily, though other edited files are OK.

Question #1 Is it possible for .htaccess reset from textpattern side?

And second problem – I need to redirect 301 old site’s links. Here’s a real example
http://www.2arhitektora.ru/52285/463604/-/- should redirect to http://2arhitektora.ru/portfolio/11/ofis-v-chemodane

Redirecting the www.domain.com -> domain.com is already done by the rule I’ve posted earlier here, so I only need to redirect people from /52285/463604/-/- to /portfolio/11/ofis-v-chemodane

I’ve googled a bit and found that I need following rule redirect 301 /52285/463604/-/- /portfolio/11/ofis-v-chemodane. But where shoud it go? Right after my new www redirect rule?

Question #2 Can anyone help me with example markup of particulary this url?

Last edited by maratnugmanov (2013-03-11 16:28:42)

Offline

#2 2013-03-11 16:44:42

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: My www redirect rule in .htaccess is disappeared?! [noob questions]

maratnugmanov wrote:

Question #1 Is it possible for .htaccess reset from textpattern side?

No. In fact Textpattern, as of v4.5.x, doesn’t write or modify any files outside from content you upload and temporary dumps. We don’t edit or reset .htaccess files or anything of that kind.

But where shoud it go? Right after my new www redirect rule?

Redirect directive is part of mod_alias module. The second argument needs to be a full URL. E.g.

Redirect 301 /52285/463604/-/- http://2arhitektora.ru/portfolio/11/ofis-v-chemodane

The ideal place for the directive is at the very top of the file, before anything else. For more information how to use it, and what it can offer, see the doc.

Last edited by Gocom (2013-03-11 16:45:42)

Offline

#3 2013-03-11 17:06:00

maratnugmanov
Member
From: Russia / Kazakhstan
Registered: 2013-02-24
Posts: 54
Website

Re: My www redirect rule in .htaccess is disappeared?! [noob questions]

Thanks alot, Gocom. I know it’s very noobish, but I’m relaunching our own site today and your answer is very detailed it will help me for sure. I’m also first time bought standalone hosting (usually i’m working with already prepared cms install), and those .htaccess redirects, rewrites are all new to me.

Offline

Board footer

Powered by FluxBB