Redirect 301 problem in .htaccess

277 views
Skip to first unread message

Soheil Novinfard

unread,
Feb 5, 2012, 4:32:52 AM2/5/12
to joomla-de...@googlegroups.com
hello everybody;

I use this code in my .htaccess file to redirect non-www addresses to www addresses of my site:

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

This is work and redirect all addresses with mysite.com to www.mysite.com/index.php;
But the problem is that I want to redirect every addresses to the exact address.
For example redirect:
mysite.com/contact to www.mysite.com/contact
and every addresses like this ...

I'm using joomla 2.5.

Any Solution?

Thanks,
Novinfard

Vladimir Prochazka

unread,
Feb 5, 2012, 6:00:39 AM2/5/12
to joomla-de...@googlegroups.com
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Soheil Novinfard

unread,
Feb 5, 2012, 12:18:49 PM2/5/12
to Joomla! General Development
Thanks, But this is not work and have same reaction.
It redirect all non-www page to www.mysite.com/index.php

Any Other solution please?

Thanks
Novinfard

On Feb 5, 2:00 pm, Vladimir Prochazka <korzi...@gmail.com> wrote:
> RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
> RewriteRule (.*)http://www.mysite.com/$1[R=301,L]
>
>
>
>
>
>
>
> On Sun, Feb 5, 2012 at 10:32, Soheil Novinfard <novinf...@gmail.com> wrote:
> > hello everybody;
>
> > I use this code in my .htaccess file to redirect non-www addresses to www
> > addresses of my site:
>
> > RewriteCond %{HTTP_HOST} ^mysite\.com [NC]
> > RewriteRule ^(.*)$http://www.mysite.com/$1[R=301,L]

Naouak

unread,
Feb 5, 2012, 3:38:25 PM2/5/12
to joomla-de...@googlegroups.com

If you want to redirect all non www users to www, you may want to do that directly by modifying the vhost of your apache. See the redirect configuration property of apache.

Soheil Novinfard

unread,
Feb 5, 2012, 5:06:46 PM2/5/12
to Joomla! General Development
I have not access to this file, is there any other way for this?

On Feb 5, 11:38 pm, Naouak <tard...@gmail.com> wrote:
> If you want to redirect all non www users to www, you may want to do that
> directly by modifying the vhost of your apache. See the redirect
> configuration property of apache.

Naouak

unread,
Feb 5, 2012, 5:27:08 PM2/5/12
to joomla-de...@googlegroups.com
you can do that in the .htaccess file.
It's something like :

Everytime someone will go to a page http://mysite.com/foo.php it will redirect to http://www.mysitecom/foo.php

Make sure you're not doing a loop in your redirection.

Naouak, Grade 2 de Kobal.
Site web: http://www.naouak.net

Soheil Novinfard

unread,
Feb 6, 2012, 6:23:28 AM2/6/12
to Joomla! General Development
You say that I must use manual way for every menu?

On Feb 6, 1:27 am, Naouak <tard...@gmail.com> wrote:
> you can do that in the .htaccess file.
> It's something like :
> Redirect /http://www.mysite.com/
>
> Everytime someone will go to a pagehttp://mysite.com/foo.phpit will
> redirect tohttp://www.mysitecom/foo.php

Naouak

unread,
Feb 6, 2012, 6:29:25 AM2/6/12
to joomla-de...@googlegroups.com
nope. The command will do that for every thing.

As I said with just the line I wrote, things like mysite.com/foo will be redirected to www.mysite.com/foo.

The "/" mean : every url that begind with "/".

Naouak, Grade 2 de Kobal.
Site web: http://www.naouak.net


shumisha

unread,
Feb 7, 2012, 6:50:42 AM2/7/12
to Joomla! General Development
Hi

You initial rule and Vladimir's slightly different ones are absolutely
fine. They are NOT the ones redirecting to /index.php (as you can see,
index.php is not mentioned anywhere in the rule).
It is probably another line(s) in your .htaccess doing that redirect,
or even possibly, though unlikely, an extension inside your Joomla
site.

Rgds
Reply all
Reply to author
Forward
0 new messages