• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Redirecting a domain name

C

CBiLL

Guest
Is there a way to redirect a domain name "http://domainname.com" to same domainname with the www "http://www.domainname.com"

I know Plesk already added it as an alias but I have a php script that is giving a cookie fits if someone was to visit our site using the domainname.com so I wanted it to redirect (add in the www to the domainname) when they visit the site by entering just the domain name without the www that the script cookie will work property.

So is there a way to redirect them to a domainname with the www in Plesk?

Thank you
Bill
 
hello,

i am using plesk 7.5.4 for windows, can you guide me from where i can redirect all the pages which are without www to with www.

for example, if i try to open domainname.com, it should automatically go to www.doomainname.com, like wise for domainname.com/abc.html should automatically go to www.domainname.com/abc.html

can you assist me, how to achieve this?
thanks, hasit
 
You don't have to rewrite conf files to do this. Make a .htaccess file and put the following in it
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) [url]http://www.domain.com/[/url]$1 [R=301,L]
Now upload it into the httpdocs directory (it won't be shown in a FTP list but it's there) and you're done. Works for any url.
 
Originally posted by Highland
You don't have to rewrite conf files to do this. Make a .htaccess file and put the following in it
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) [url]http://www.domain.com/[/url]$1 [R=301,L]
Now upload it into the httpdocs directory (it won't be shown in a FTP list but it's there) and you're done. Works for any url.

this is a windows server will .htaccess work?
 
This is a UNIX forum ;) But I can help you anyways.

Unfortunately IIS doesn't support this natively. You can get around this by using ISAPI Rewrite which makes IIS work like Apache. Sadly the full version costs money but appears to be cheap per server.

http://www.isapirewrite.com/
 
Many thx Highland, I have been wondering how to do that :)

Do you know if this rule can be set up in Plesk as a default for *all* new domains? I'm asking because I read somewhere that it is not recommended for SEO purposes to allow two access points (http & www) for websites.

Also (and forgive me for asking but I am a complete Plesk VPS newbie) why does this work at all with an htaccess file?. Searching this forum, the advice seems to be to use vhost.conf files to set up mod_rewrite rules for domains?
 
Do you know if this rule can be set up in Plesk as a default for *all* new domains? I'm asking because I read somewhere that it is not recommended for SEO purposes to allow two access points (http & www) for websites.
Unfortunately there's no way to do this by default that I know of. I suppose it's possible to write a script to do this but that's beyond my knowledge. It shouldn't be hard to edit this for each domain, tho.

Also (and forgive me for asking but I am a complete Plesk VPS newbie) why does this work at all with an htaccess file?. Searching this forum, the advice seems to be to use vhost.conf files to set up mod_rewrite rules for domains?
vhost.conf is used to configure how Apache sets up the TLD and how PHP is processed. htaccess is used to control how the domain is processed when requests are received. I don't think you can put mod_rewrite rules into vhost.conf
 
Originally posted by Peekay
Also (and forgive me for asking but I am a complete Plesk VPS newbie) why does this work at all with an htaccess file?. Searching this forum, the advice seems to be to use vhost.conf files to set up mod_rewrite rules for domains?
I just set up mod_rewrite for a dynamic site on a domain using htaccess without going near conf files. This really needs some clarification in the Plesk instructions IMHO 'cos it's a useful feature.
 
Back
Top