我正在浏览我的网站seo,在阅读了一些我发现的关于seo友好网址的文章后,我决定将所有动态网址更改为静态网址。
例如:大多数网址都像www.abc.com/final.php?id=1&name=name-of-file
但我想将网址更改为静态网址,例如www.a.com/name-of-file/1
我尝试编辑.htaccess文件,但它无效。
我的.htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteRule final/id/(.*)/name/(.*)/ final.php?id=$1&name=$2
答案 0 :(得分:1)
尝试这样,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/([\d]+)$ final.php?id=$2&name=$1 [QSA,NC,L]
答案 1 :(得分:0)
您可以使用:
Options +FollowSymLinks
RewriteEngine on
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+final\.php\?id=([^\s&]*)&name=([^\s&]*) [NC]
RewriteRule ^ /%2/%1/? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(\d+)/? final.php?id=$2&name=$1 [NC,L,QSA]