Mod_Rewrite和网站链接结构
我有一个具有以下结构的网站:
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
那么有什么想法吗?
I have a website with this structre
index.php / home.php / profile.php / news.php / photos.php
newsfeed.php - for news article
photo.php - for photo
there is also username for users to get short link for his profile like
mysite.com/UserName
now I'm using this code in .htaccess to rewrite URLS of username
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/]+)/?$ profile.php?u=$1 [L]
now I want to rewrite all my links to be SE-Friendly like this
index.php --> index
home.php --> home
photos.php --> photos
videos.php --> videos
newsfeed.php?id=xx --> news/xx
photo.php?id=xx --> photo/xx
So any idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我要做的:
然后像这样添加它们。
Here's what I'd do:
And just add them on like so.