我有以下URL
www.example.com/index.php?tag= xxx
我想使用 .htaccess 让它变成以下这样。
www.example.com/xxx
我用以下代码完成了它:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ /index.php?tag=$1 [L,QSA]
如果我输入这个URL:
www.example.com/index.php?tag=1000
将其重定向到:
www.example.com/?tag=1000
如果访问 www.example.com/1000
可以正常显示,则说明该链接有效!
因此,我有重复的URL,这对SEO并不好。
如何将 www.example.com/index.php?tag=1000
重定向到 www.example.com/1000
?
index.php?tag=$1
,可以获取$_GET['get']']
。 - anubhava