Welcome Guest, Not a member yet? Register   Sign In
codeigniter url_suffix ( .html) issue
#1

Hello guys..

i have been using codeigniter over 7 years.recently i start using $config['url_suffix'] = '.html'; feature

After that when i checked google web master tool,it detecting two different url version

example:-

http://www.example.com/news
http://www.example.com/news.html

Problem is http://www.example.com/news not redirecting to http://www.example.com/news.html automatically. 

so google bot mark http://www.example.com/news as duplicate page Sad

is anyway to force avoid this case?i try to check current url have .html,if not use 301 redirect to .html url version..

but even for http://www.example.com/news

Code:
echo current_url();

out put http://www.example.com/news.html Confused

Please help
Reply
#2

This are a job for your server (nginx or Apache) to fix. Haven't written such a rule, so can't give you any real tips there.

May I ask why you are doing it in the first place? You also set an canonical url and Google will pick it up as an alias instead.
Reply
#3

(06-08-2020, 11:18 AM)jreklund Wrote: This are a job for your server (nginx or Apache) to fix. Haven't written such a rule, so can't give you any real tips there.

May I ask why you are doing it in the first place? You also set an canonical url and Google will pick it up as an alias instead.

i like to use .html for all urls,that give clear url structure,while some users think site create using html Cool

i solved problem using
Code:
$escaped_url = html_escape( remove_invisible_characters($_SERVER['REQUEST_URI']));
if( strpos( $escaped_url, ".html" ) === false) {
    redirect ( current_url(), 'location', 301 );
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB