[英].htaccess redirect and visible URL
I'm new to htaccess and I want to know how can I do this two things and if they are recommended or if is there another better way to achieve a SEO friendly and nice URL: 我是htaccess的新手,我想知道我该怎么做这两件事,以及是否建议使用它们,或者是否还有另一种更好的方法来实现SEO友好且美观的URL:
You can use this code in your DOCUMENT_ROOT/.htaccess
file: 您可以在
DOCUMENT_ROOT/.htaccess
文件中使用以下代码:
RewriteEngine On
RewriteBase /example/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /products(?:\.php)?\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ products.php?id=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.