Jump to content

How to redirect my website URL


Recommended Posts

When I type my web address with www, everything will be fine. But when I type my address without www, it will show 404 page. I think my website needs to be redirected.  I could not find htaccess file from the file folder of the C-panel. Can someone please let me know how to find the htaccess file or create a htaccess file. If it possible, please write down the code here as well. Thanks.

Link to comment
Share on other sites

You can open up notepad or text editor and type in the following code:

 

RewriteEngine on
 rewritecond %{http_host} ^yourwebsite.com [nc]
 rewriterule ^(.*)$ http://www.yourwebsite.com/$1 [r=301,nc]
 
and save the file as .htaccess with the Save as type set to "All Files" Put it in your root directory. If this doesn't work the Rewrite Engine might be turned off on your server.
  • Like 1
Link to comment
Share on other sites

One more question. Why my website is soooo slow after uploading the .htaccess file?

 

I copied the code"<IfModule mod_rewrite.c>

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


</IfModule>" and saved it into text editor, named it as1.htaccess, then, uploaded into my root directory. Is there anything wrong?

Link to comment
Share on other sites

When I type my web address with www, everything will be fine. But when I type my address without www, it will show 404 page. I think my website needs to be redirected.  I could not find htaccess file from the file folder of the C-panel. Can someone please let me know how to find the htaccess file or create a htaccess file. If it possible, please write down the code here as well. Thanks.

you can do it easily on your cpanel of the website

Link to comment
Share on other sites

One more question. Why my website is soooo slow after uploading the .htaccess file?

 

I copied the code"<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.

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

</IfModule>" and saved it into text editor, named it as1.htaccess, then, uploaded into my root directory. Is there anything wrong?

 

Here they tell us using .htaccess is bad for httpd (apache) peformance.

http://httpd.apache.org/docs/2.2/howto/htaccess.html#page-header

 

we get lazy using .htaccess, and as they say the 'the lazy work twice'

Link to comment
Share on other sites

I usually name it just .htaccess without any file name in front of it. I don't know if that could have anything to do with it.

 

httpd configuration file is not accessible via FTP.

 

what they suggest is rather than using the .htaccess file, that it be done at apache configuration level.  contact your hosting company on how/if you can manage apache configuration.  Honestly we tell people put this in .htaccess as a general rule because they know what that is and they can access it using FTP.

Link to comment
Share on other sites

×
×
  • Create New...