5 replies
Hi , i bought a script from someone , and installed the script with the installer that came with it , but I need to remove www from the url , i searched the web and found that i need to edit the .htaccess file , but their was no such file in the public_html directory of my domain, i added via cpanel...so i created a .htaccess file and added the following code to it ...

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

But still the url with www, does not redirect to the non www url , same thing happens with internal urls as well ..

Can anyone please help ?
#remove #www
  • Profile picture of the author desingshop98
    Can anyone please help ?
    {{ DiscussionBoard.errors[7696465].message }}
  • Profile picture of the author desingshop98
    Ok , so i found out that my server is running nginx and now i need to figure out how to redirect a www url to non www url in nginx , any help is appreciated.

    Here is the website with www , if it helps - Descargar musica
    {{ DiscussionBoard.errors[7696922].message }}
    • Profile picture of the author Bruce Hearder
      Hi desingshop98,

      Nginx does not use htaccess file. So creating one will have no effect at all.

      If you want to convert a htaccess file across to NGINX format, then you can use a tool like :

      http://winginx.com/htaccess

      You will need to edit you Nginx config file (nginx.conf) to look something like:

      # nginx configuration

      location / {
      if ($http_host ~* "^www.example.com$"){
      rewrite ^(.*)$ http://example.com/$1 redirect;
      }
      }

      I hope this helps

      Bruce
      {{ DiscussionBoard.errors[7698370].message }}
  • Profile picture of the author desingshop98
    Thank you Bruce , i was finally able to locate the nginx.conf file and I have added the block of text gave ...It works perfectly now with some changes that i found via google...

    For anyone out their who might need help with this ...this is the code that i have placed at the very top of my nginx config file for the domain...

    server {
    listen DOMAIN IP HERE;
    server_name www.YOUR-DOMAIN.com;
    return 301 $scheme://YOUR DOMAIN.com$request_uri;
    }

    Bruce , thanks again for guiding me in the right direction ...
    {{ DiscussionBoard.errors[7699294].message }}
    • Profile picture of the author Bruce Hearder
      No probelms, glad things worked out OK..
      {{ DiscussionBoard.errors[7702613].message }}

Trending Topics