Redirect from http://www.myadress.com to http://myadress.com

apfan

Member
Jun 6, 2005
23
0
151
Iceland
Is there any kind of code ill could place in the "ht acess" file. To make this redirect possible.

Regards
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
This looks straightforward enough, but I can't get it to take. It just acts like it's not matching at all, and continues to display the "www" in the URL. Any follow-up tips?

Thanks.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
This looks straightforward enough, but I can't get it to take. It just acts like it's not matching at all, and continues to display the "www" in the URL. Any follow-up tips?

Thanks.
The code should be placed in a .htaccess file in the public_html directory (assuming this is the primary domain for that cPanel account).

Is there any other code in the .htaccess file by chance? I know WordPress in particular wreaks all sorts of havoc with .htaccess files causing redirects and some cPanel functionality relying on .htaccess to not function properly.
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
Hi David - No, I'm working in a vhost conf file:

Code:
/usr/local/apache/conf/userdata/std/2/news23/news23project.domain.org
all other apache directives in that file work fine - just not that one.
 

shacker23

Well-Known Member
Feb 20, 2005
263
1
168
Aha! Progress. I realized that it wasn't matching because we needed to be putting these in a

Code:
/usr/local/apache/conf/userdata/std/2/news23/[B]www[/B].news23project.domain.org
directory. Now I've got it working for the base URL but URLs like

http://www.domain.org/projects

redirects to the homepage not to /projects. What's wrong with this picture?

Code:
# Get useless and ugly www out of the URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.org$
RewriteRule ^(.*)$ http://domain.org/$1 [R=301,L]
Thanks,
./s