且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用htaccess的缩短网址

更新时间:2023-11-27 20:25:52

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在的.htaccess $ DOCUMENT_ROOT 目录下:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# from /obj/task/profile/id/1568/username
# to /1568/username
RewriteRule ^obj/task/profile/id(/.+)$ /$1 [R=302,L,NC]

# from obj/task/page/city/41280/pageId/22/clubs//Test%20town
# to 41280/22/clubs//Test%20town
RewriteRule ^obj/task/page/city/([^/]+)/pageId(/.+?)/?$ /$1/$2 [R=302,L,NC,NE]