Fórum

Redirect to non www to www version

nidheesh ks, modificado 12 Anos atrás.

Redirect to non www to www version

New Member Postagens: 23 Data de Entrada: 26/07/11 Postagens Recentes
Hi ,

I have multiple portal instances.
For a instance Ii gave virtual host without "www", then created an organization in the instance and I gave virtual host with "www" .
Now I want all my request to be redirected to "www" version if at all the user does'nt enter it in the url

Thanks in advance,

Nidheesh
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Redirect to non www to www version

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
I have no idea on how to do this on just tomcat or so.. but using a web server in front it can be done... see this http://www.scriptalicious.com/blog/2009/04/redirecting-www-to-non-www-using-htaccess/
nidheesh ks, modificado 12 Anos atrás.

RE: Redirect to non www to www version

New Member Postagens: 23 Data de Entrada: 26/07/11 Postagens Recentes
Hi Ravi,
Thanks for you reply.
I understand what you mean , but for that i have to install apche on my server and proxy all request to tomcat right?.
I saw that when we type "liferay.com" in browser it gets redirected to "www.liferay.com", so I think there may be another way, or else liferay website is also doing the same with apache redirect.

Thanks
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: Redirect to non www to www version

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
nidheesh ks:

I understand what you mean , but for that i have to install apche on my server and proxy all request to tomcat right?.

You are right.. emoticon

nidheesh ks:

I saw that when we type "liferay.com" in browser it gets redirected to "www.liferay.com", so I think there may be another way, or else liferay website is also doing the same with apache redirect.

I guess Liferay is using CDN.. check all the requests of a page when you open liferay.com emoticon
nidheesh ks, modificado 12 Anos atrás.

RE: Redirect to non www to www version

New Member Postagens: 23 Data de Entrada: 26/07/11 Postagens Recentes
Hi,

For getting into a solution for this I tried creating a servlet filter which redirects all request coming without www to www.
Then I added it to liferay web.xml and the jar to lib folder and it seems working.
The only thing I missed is the order of the filter chain. Although my filter is defined first it is coming after vitual host filter I think, because www is getting appended but "web/org-name" is coming with it .
qingsheng fu, modificado 11 Anos atrás.

RE: Redirect to non www to www version

New Member Postagens: 11 Data de Entrada: 25/03/11 Postagens Recentes
you can use the url rewriter. in the ROOT/WEB-INF, find the urlrewite.xml and add a new rule

<rule>
<name>Domain Name Check</name>
<condition name="host" operator="notequal">www.example.com</condition>
<from>^(.*)$</from>
<to type="redirect">http://www.example.com$1</to>
</rule>
thumbnail
Dominik domih, modificado 10 Anos atrás.

RE: Redirect to non www to www version

Junior Member Postagens: 57 Data de Entrada: 10/11/08 Postagens Recentes
Thank you qingsheng! You redirect everything except www.example.com to http://www.example.com.

I wanted to share my modified version, which redirects naked URLs to www URLs for single domain names like example.com.

        <rule>
                <name>Domain Name Check for example.com</name>
                <condition name="host" operator="equal">^example.com</condition>
                <from>^(.*)$</from>
                <to type="redirect">http://www.example.com$1</to>
        </rule>

This redirects non-www URLs to www URLs. So every pagehit that comes to example.org gets redirected to www.example.org. With this you can have multiple domains on one server.
Ghazala sabir, modificado 7 Anos atrás.

RE: Redirect to non www to www version

New Member Postagens: 3 Data de Entrada: 03/09/15 Postagens Recentes
I used below Redirect URL rule but its also redirect wrong url to my site.
For example its redirect zzzzzzz.example.com to my site.This is not what I want.Please suggest

<rule>
2 <name>Domain Name Check for example.com</name>
3 <condition name="host" operator="equal">^example.com</condition>
4 <from>^(.*)$</from>
5 <to type="redirect">http://www.example.com$1</to>
6 </rule>