How to resolve 301 Redirect issue?

Started by DipakS, February 19, 2018, 04:42:46 PM

Previous topic - Next topic

DipakS

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,

Gandhar Kulkarni

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.
█ MilesWeb - Your Hosting, Our Responsibility!
Buy Web Hosting @ ₹60/mo
VPS Hosting | WordPress Hosting | Reseller Hosting

Anu

You need to consult the expert designer or hosting provider to sort such technical issues.

Lokesh

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. :)

EKTA TRIPATHI

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.
█ MilesWeb - Your Hosting, Our Responsibility!
█ Reseller Hosting @ ₹320/mo - SSD NVMe Storage & Bandwidth | Reseller Control Panel
24x7 Support

Ritu

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" );
?>

DipakS

#6
Thank you friends, for the suggestions!!! I will implement this on my website. :)