Pedro Chagas
asked on
Url Friendly - redirect 301 or 200
Hi E's,
In this question I get a solution for have friendly URL's in my project: https://www.experts-exchange.com/questions/28484783/Mod-rewrite-Information-from-data-base.html.
What this solution does is check the URL, and if the URL does not exist redirects to router.php. Router.php analyze the URL, and if the friendly URL exists, redirect to the current page. Example: Friendly URL = domain.com/friendly-url correspond to domain.com/friendly_url-ph p?bla=bli, if I write domain.com/friendly-url router.php send to the page domain.com/friendly_url-ph p?bla=bli.
This photo shows how the system works:The system work perfect, the problem is Google assumes a 302 Redirect, when the correct is 301 (the page has been moved permanently) or maybe 200 (the server successfully returned the page).
I thing the problem is the code of .htaccess, don't inform the type of redirect:
I try change the last line to:
Router.php have this code
What changes I have to do for the redirect be 301 or 200?
The best regards, JC
In this question I get a solution for have friendly URL's in my project: https://www.experts-exchange.com/questions/28484783/Mod-rewrite-Information-from-data-base.html.
What this solution does is check the URL, and if the URL does not exist redirects to router.php. Router.php analyze the URL, and if the friendly URL exists, redirect to the current page. Example: Friendly URL = domain.com/friendly-url correspond to domain.com/friendly_url-ph
This photo shows how the system works:The system work perfect, the problem is Google assumes a 302 Redirect, when the correct is 301 (the page has been moved permanently) or maybe 200 (the server successfully returned the page).
I thing the problem is the code of .htaccess, don't inform the type of redirect:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ router.php [L]
I try change the last line to:
RewriteRule ^.*$ router.php [R=301,L]
But not workRouter.php have this code
<?php
//I will check url and redirect page based and that url
header( "Location: article.php?id=878" ) ;
?>
What changes I have to do for the redirect be 301 or 200?
The best regards, JC
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In your opinion, in this case, what is the best redirect, 301 or 200?
The best regards, JC