简体   繁体   English

htaccess从旧网址重定向到新的友好网址不起作用

[英]htaccess redirect from old url to new friendly url not working

i've working on a ecommerce website, and on the landing page there are several products which user can see, if a user wants to see more details about a particular product he has to click on it which will then take him to viewproduct.php?productname=fidget-spinner&code=12345&id=12345 我正在一个电子商务网站上工作,并且在登录页面上有几款产品可供用户查看,如果用户想查看有关某个特定产品的更多详细信息,则必须单击该产品然后将其带到viewproduct.php ?产品名=狂燥微调&码= 12345&ID = 12345

what i want is when a user clicks on a product URL should be this : viewproduct.php/productname/fidgetspinner/code/12345/id/12345 当用户单击产品URL时,我想要的是这样:viewproduct.php / productname / fidgetspinner / code / 12345 / id / 12345

I am able to create a seo friendly url using htaccess but i have to go to viewproduct.php?productname=fidget-spinner&code=12345&id=12345 and then manually in the url i have to type the friendly url which works fine..i want seo friendly user to be displayed when a user clicks on viewproduct.php 我可以使用htaccess创建一个seo友好的url,但是我必须转到viewproduct.php?productname = fidget-spinner&code = 12345&id = 12345,然后手动在该url中输入必须工作正常的友好url。当用户单击viewproduct.php时将显示seo友好用户

any new suggestions would be appreciated!! 任何新的建议,将不胜感激!

NEW FRIENDLY SEO URL : 新的友好SEO网址:

Options +FollowSymLinks
RewriteEngine on
RewriteRule www.example.com/productname/(.*)/code/(.*)/id/(.*)$ viewproduct.php?productname=$1&code=$2&id=$3

this is what i've tried until now to redirect to new url when a user clicks on a product : 这是我到目前为止尝试过的操作,当用户单击产品时,该重定向到新的URL:

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^www.example.com/productname/([a-z0-9]+)/code/([0-9]+)/id/([a-z0-9-]+)?$ viewproduct.php?productname=$1&code=$2&id=$3 

try this 尝试这个

//Redirect old file path to new file path//

Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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