Jump to content

set a rule for seo_path


jpayam

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...