-1

I am developing an application in CodeIgniter. I got some issues from SEO expert. One issue is URL Canonical issue.

For Example, I can access the same content by multiple URLs.

https://seocompany.us.com/portfolio

https://seocompany.us.com/portfolio/

https://seocompany.us.com/index.php/portfolio/

https://seocompany.us.com/index.php/portfolio

How to redirect all these URLs to only 1 URL.

https://seocompany.us.com/portfolio

Bikram Pahi
  • 1,107
  • 1
  • 12
  • 33

2 Answers2

1

a 301 rewrite would also work for directing them

301 --- https://seocompany.us.com/index.php/portfolio/ => https://seocompany.us.com/portfolio

RewriteRule ^index\.php/portfolio/$ /portfolio? [L,R=301]

and so on

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
  • It is working fine for both the urls `https://seocompany.us.com/index.php/portfolio/` and `https://seocompany.us.com/index.php/portfolio` but not for this `https://seocompany.us.com/portfolio/`. My `.htaccess` code is `RewriteRule ^index\.php/portfolio/$ /portfolio? [L,R=301] RewriteRule ^index\.php/portfolio$ /portfolio? [L,R=301] RewriteRule ^/portfolio/$ /portfolio? [L,R=301]` – Bikram Pahi May 05 '17 at 08:41
0

At end of .htaccess file add this. (didn't check)

RewriteCond %{HTTP_HOST} ^seocompany.us.com/index.php/portfolio/ [NC]
RewriteRule ^(.*)$ https://seocompany.us.com/portfolio/$1 [L,R=301]
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • Dear @AbdullaNilam Thanks for the solution. But unfortunately, this solution is not working. I have added the code in my `.htaccess` file. – Bikram Pahi May 04 '17 at 15:31