【发布时间】:2011-12-18 10:46:25
【问题描述】:
我有一个具有这种结构的网站
index.php/home.php/profile.php/news.php/photos.php
newsfeed.php - 用于新闻文章
photo.php - 用于照片
还有用户名供用户获取他的个人资料的短链接,例如
mysite.com/UserName
现在我在 .htaccess 中使用此代码来重写用户名的 URL
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/]+)/?$ profile.php?u=$1 [L]
现在我想像这样重写我的所有链接,使其对 SE 友好
index.php --> index
home.php --> home
photos.php --> photos
videos.php --> videos
newsfeed.php?id=xx --> news/xx
photo.php?id=xx --> photo/xx
有什么想法吗?
【问题讨论】:
标签: php .htaccess mod-rewrite seo