我想把http://example.com/test/index.php?id=123重写为http://example.com/test/item/123/,http://example.com/test/index.php?id=123重定向到人类友好的url。
我不知道我的htaccess有什么问题:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /test/
RewriteCond %{QUERY_STRING} ^id=([a-z0-9]+)$ [NC]
RewriteRule ^/item/%1/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^item/([a-z0-9]+)/$ index.php?id=$1 [L]发布于 2019-05-03 18:24:11
您可以在您的RewriteRule文件中使用以下/test/.htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine on
#redirect old url to the new one
RewriteCond %{THE_REQUEST} /test/index\.php\?id=([^\s]+) [NC]
RewriteRule ^ /test/item/%1? [L,R=301]
#internally map new url to the old one
RewriteRule ^item/(.+)/?$ /test/index.php?id=$1 [L,NC]https://stackoverflow.com/questions/55975156
复制相似问题