简体   繁体   中英

Canonical URL without trailing slash for file/path

I have a site based on Codeignitor(theinnovativepackaging.com). From SEO perspective I have read that trailing slashes in Root URL doesn't matter but it does matter for file/paths eg /about-us and /about-us/ as far as I have studied about it. My problem is that my sites pages have trailing slash in URL but when you view page source and check if canonical URL matches but I doesn't see any trailing slash there. So does it matter if I have URL structure like this URL in address bar: example.com/product-name/ canonical URL: example.com/product-name. As far as I have studied its not good habit according to SEO. If it is ok then let me know or if its not kindly guide me how can I add trailing slash in product pages. I am attaching my sites .htaccess

 <IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,NE,L]


RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1/$2 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

My main goal is to keep canonical tag and URL in address bar same if it really impacts SEO

The value of the rel="canonical" link element (which I assume is what you mean by the "canonical tag") should contain your canonical URL. If you are linking/using a different URL in your internal links then you are misrepresenting the canonical URL in your "canonical tag".

Yes, the two should be the same. So, you either need to append the trailing slash in your "canonical tag", or remove the trailing slash in your internal links.

If you are consistently linking to the URL with the trailing slash then Google will likely ignore your "canonical tag" that omits it.

I am attaching my sites .htaccess

Your .htaccess file would seem to be irrelevant here. You are not forcing (or removing) the trailing slash here. (You could later add a canonical redirect to force one or the other, should the non-canonical URL be requested.)

However, your immediate problem is not something you would resolve in .htaccess anyway. You need to correct your internal links OR the "canonical tag".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM