Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-26 16:53:23

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

Redirecting /index.php (or not)?

I searched, but didn’t find the answer for this:

I know that http://mysite.com and http://www.mysite.com are two different pages. And its good for SEO purposes to do a redirection on one of those two pages, which I did in .htaccess file

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

but what about http://www.mysite.com/index.php isn’t that another page that should be redirected to the http://www.mysite.com/ ?

And if so, how would I do that? Because this code doesn’t do that.

Thanks!

Offline

#2 2009-03-27 16:10:36

katlazy08
New Member
From: Manchester
Registered: 2009-03-27
Posts: 2
Website

Re: Redirecting /index.php (or not)?

something like this…

RewriteEngine On
#Redirect plain index.php to home page without index.php
RewriteCond %{IS_SUBREQ} false
RewriteRule ^/index\.php$ http://www.mysite.com [R=301,L]

Offline

#3 2009-03-27 19:05:56

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

Re: Redirecting /index.php (or not)?

Thanks, but I can’t get it to work. Here’s how my .htaccess file looks like:

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
Options All -Indexes

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_HOST} ^mysite.com [NC]
        RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
	#RewriteBase /relative/web/path/

        RewriteCond %{IS_SUBREQ} false
        RewriteRule ^/index\.php$ http://www.mysite.com [R=301,L]

        RewriteCond %{HTTP_REFERER} !^$
        RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/.*$ [NC]
	RewriteRule .(gif|jpg|png)$ - [F] 

	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>

<files .htaccess>
order allow,deny
deny from all
</files>

# limit file uploads to 10mb
LimitRequestBody 10240000

# protect config.php
<files config.php>
order allow,deny
deny from all
</files>

#php_value register_globals 0

as you can see, I added what you suggested in the middle, but its not working. I’m not sure if I add it the right way…

Last edited by AndrijaM (2009-03-27 19:06:10)

Offline

#4 2009-04-02 10:02:20

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

Re: Redirecting /index.php (or not)?

Can somebody please tell me is it safe to remove the

<IfModule mod_rewrite.c>
...
</IfModule>

from the delault textpattern .htaccess file. This is how my .htaccess file looks now:

Options All -Indexes
#Options +FollowSymLinks

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.mysite.com/$1 [R=301,L] 

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/.*$ [NC]
RewriteRule .(gif|jpg|png)$ - [F] 

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}]

<files .htaccess>
order allow,deny
deny from all
</files>

# limit file uploads to 10mb
LimitRequestBody 10240000

# protect config.php
<files config.php>
order allow,deny
deny from all
</files>

#php_value register_globals 0

and with this everything works the way I want, just want to be sure if it is ok like this.

Last edited by AndrijaM (2009-04-02 10:02:45)

Offline

Board footer

Powered by FluxBB