MilesWeb Hosting Forum

Web Hosting Main Forums => SEO / Social Media Discussions => Topic started by: DipakS on February 19, 2018, 04:42:46 PM

Title: How to resolve 301 Redirect issue?
Post by: DipakS on February 19, 2018, 04:42:46 PM
Hello Everyone,

I need your help, I have added 301 to the main page and its working properly.
Example: from http://example.com to http://www.example.com

But as I apply the same method to my website inner pages I am facing some issues like it's not working properly and getting redirected to the home page with index.php
For example: If I load this link in my browser: http://www.example.com/test.html
It's redirecting me to http://example.com/index.php

I am not sure, what went wrong and why it is showing the index.php page at the end of my URL.

Please help me,
Title: Re: How to resolve 301 Redirect issue?
Post by: Gandhar Kulkarni on February 21, 2018, 12:23:22 PM
Quote from: DipakS on February 19, 2018, 04:42:46 PM
Hello Everyone,

I need your help, I have added 301 to the main page and its working properly.
Example: from http://example.com to http://www.example.com

But as I apply the same method to my website inner pages I am facing some issues like it's not working properly and getting redirected to the home page with index.php
For example: If I load this link in my browser: http://www.example.com/test.html
It's redirecting me to http://example.com/index.php

I am not sure, what went wrong and why it is showing the index.php page at the end of my URL.

Please help me,

Try this one

Add following lines in your htaccess file.

RewriteEngine on
RewriteRule ^$ http://www.example.com/ [R=301,L]

replace example.com with different url (where you would like to redirect)


I hope it will work.
Title: Re: How to resolve 301 Redirect issue?
Post by: Anu on February 21, 2018, 06:11:58 PM
You need to consult the expert designer or hosting provider to sort such technical issues.
Title: Re: How to resolve 301 Redirect issue?
Post by: Lokesh on February 23, 2018, 04:27:11 PM
Quote from: DipakS on February 19, 2018, 04:42:46 PM
Hello Everyone,

I need your help, I have added 301 to the main page and its working properly.
Example: from http://example.com to http://www.example.com

But as I apply the same method to my website inner pages I am facing some issues like it's not working properly and getting redirected to the home page with index.php
For example: If I load this link in my browser: http://www.example.com/test.html
It's redirecting me to http://example.com/index.php

I am not sure, what went wrong and why it is showing the index.php page at the end of my URL.

Please help me,


In order to redirect /home and /index to the root and return all non www addresses to www, You can add the following to your .htaccess in the root of the /public folder,

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\."yoursite"\.com
RewriteRule (.*) http://www.example.com/ [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.. [R=301,L]

I hope it will work. :)
Title: Re: How to resolve 301 Redirect issue?
Post by: EKTA TRIPATHI on February 24, 2018, 05:37:09 PM
Quote from: Gandhar Kulkarni on February 21, 2018, 12:23:22 PM
Quote from: DipakS on February 19, 2018, 04:42:46 PM
Hello Everyone,

I need your help, I have added 301 to the main page and its working properly.
Example: from http://example.com to http://www.example.com

But as I apply the same method to my website inner pages I am facing some issues like it's not working properly and getting redirected to the home page with index.php
For example: If I load this link in my browser: http://www.example.com/test.html
It's redirecting me to http://example.com/index.php

I am not sure, what went wrong and why it is showing the index.php page at the end of my URL.

Please help me,

Try this one

Add following lines in your htaccess file.

RewriteEngine on
RewriteRule ^$ http://www.example.com/ [R=301,L]

replace example.com with different url (where you would like to redirect)


I hope it will work.

Yes, you can use this method because I have clarified this issue by using the same method.
Title: Re: How to resolve 301 Redirect issue?
Post by: Ritu on February 27, 2018, 01:06:52 PM
Alternative Methods to Implement a 301 Redirect
If you do not have access to your .htaccess file or your Windows Server Administration Panel, you can still perform 301 redirects with the code on your old pages.
If your website pages are in PHP, ASP, Java, or any other language that allows you to modify response headers, simply place code at the top of each page to do the permanent redirect.

Ex. PHP Redirect
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com" );
?>
Title: Re: How to resolve 301 Redirect issue?
Post by: DipakS on February 27, 2018, 01:10:25 PM
Thank you friends, for the suggestions!!! I will implement this on my website. :)