'RewriteRule and seo friendly address
So far, my website has been working on the following addresses: domain.com/item.php?id=XXXXXXXXXXXXXXX
I wanted to change to seo friendly addresses and added to htaccess
RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -D
RewriteRule ^item/([^/]{14}) /item.php?id=$1 [L]
And it works great after entering the address:
domain.com/item/XXXXXXXXXXXXXXX
the content of the relevant page is displayed.
So that there would be no problem with duplicate content in the page code, I added:
<link rel = "canonical" href = "https://www.domena.com/item/XXXXXXXXXXXXXXX" />
I am only wondering that google has both url addresses indexed now. Shouldn't it be done on 301 redirects and if so, how, because in rewrite rules I'm not too strong? Thank you in advance for the hint.
I tried also writing [R=301,L] instead of [L] but then if I click address:
domain.com/item/XXXXXXXXXXXXXXX
in address field of the browser I can see:
domain.com/item.php?id=XXXXXXXXXXXXXXX
Greetings,
Mark
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
