jpayam Posted September 19, 2016 Share Posted September 19, 2016 Hi How can i set a rule in .htaccess that index.php?seo_path=my-seo-path 301 redirect to domain.com/my-seo-path.html as i see many index.php?seo_path=my-seo-path on Webbots and this is bad for seo. Quote Link to comment Share on other sites More sharing options...
bsmither Posted September 19, 2016 Share Posted September 19, 2016 Please try: RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{QUERY_STRING} ^(.*&)?seo_path=(.*)(&.*)?(#.*)?$ RewriteRule ^(.*)$ http://www.mydomian.com/%2.html?%1%3%4 [L,R=301] The way I see this (I haven't actually tried it) is: The URL is split into parts. Two of those parts are the REQUEST_URI (path/document) and the QUERY_STRING. The first condition that must be met is the path/document must be /index.php. The second condition is that querystring can start with (anything followed by an ampersand) that may or may not be there, followed by the literal seo_path=(anything), followed by (an ampersand followed by anything) that may or may not exist, followed by (a fragment) that may or may not exist. What we do not want to lose is any other part of the querystring while subtracting out the seo_path part. Some examples (again, I haven't tested these): index.php?seo_path=my-seo-path => /my-seo-path.html? index.php?sort=price|asc&seo_path=my-seo-path => /my-seo-path.html?sort=price|asc& index.php?sort=price|asc&seo_path=my-seo-path&page=3 => /my-seo-path.html?sort=price|asc&&page=3 I do not know what consequences there are for having trailing or doubled ampersands. Playing with Google with edited search URLs seems to have no bad effects. But your predicament begs the question... How would outside parties have URLs to your store having that format? CC6 should not ever send out a URL with seo_path in the querystring. Quote Link to comment Share on other sites More sharing options...
jpayam Posted September 20, 2016 Author Share Posted September 20, 2016 Provided code not works correctly Duplicate content can be a major source of SEO problems. When duplicate content is present, site owners suffer rankings and traffic losses, and search engines provide less relevant results. we have 2 URL with same content . 1- domain.com/index.php?seo_path=my-seo-path 2- domain.com/my-seo-path.html Check this link for more info : https://moz.com/learn/seo/duplicate-content Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.