通配符子域和友好 URL
这就是我想对 htaccess (或您建议的任何内容)做的事情:
我希望允许用户发布页面、照片、视频……并为他们每个人提供一个自己选择的子域(例如: john. mysite.com
)。
下面介绍了 URL 的样子 - 真正像 Tumblr(如果它能像 Tumblr 一样工作那就太好了:) -
john.mysite.com/photos
john.mysite.com/photos/album/123456789
john.mysite.com/news/123456789
john.mysite.com/news/category/123456789
使用 htaccess 我可以让 whatevertheusernameis.mysite.com
由 mysite 提供服务。 com/user.php
然后在user.php
中,我可以看到用户正在分析HTTP_HOST
(获取'whatevertheusernameis'并检查我的数据库),并且我可以知道要显示什么(照片,视频,新闻、页面...)正在阅读 REQUEST_URI
。
我希望某些 URL 按如下方式工作:
john.mysite.com/ajax/ajax.php -> mysite.com/ajax/ajax.php
john.mysite.com/images/img.png -> mysite.com/images/img.png
但是,例如,如果我在 john.mysite.com/photos/album/123456789/
中,则该 URL 将作为 john.mysite .com/photos/album/123456789/ajax/ajax.php
当然,这是行不通的...
有人可以帮助我吗?谢谢。
This is what I would like to do with htaccess (or whatever you suggest):
I want to allow users to publish pages,photos,videos,... and give them each a subdomain of their choice (ex: john.mysite.com
).
Here's how a URL can be -really Tumblr like (it would be great if it'd work like Tumblr :)-
john.mysite.com/photos
john.mysite.com/photos/album/123456789
john.mysite.com/news/123456789
john.mysite.com/news/category/123456789
Using htaccess I can make whatevertheusernameis.mysite.com
be served by mysite.com/user.php
Then in user.php
I can see who the user is analyzing HTTP_HOST
(getting 'whatevertheusernameis' and checking my DB) and I can know what to show (photos,videos,news,pages,...) reading REQUEST_URI
.
I would like certain URL to work as follow:
john.mysite.com/ajax/ajax.php -> mysite.com/ajax/ajax.php
john.mysite.com/images/img.png -> mysite.com/images/img.png
but if, for example, I'm in john.mysite.com/photos/album/123456789/
this will be served as john.mysite.com/photos/album/123456789/ajax/ajax.php
that, of course, won't work...
Can anyone please help me? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要做的就是在所有其他重写之前添加一个条件:
这些指令将告诉 Apache 始终提供实际文件 (f)、目录 (d) 和符号链接 (l),并使用子域来标识用户数据(照片等)。
What you have to do is add a condition before all your other rewrites:
Those directives will tell Apache to always serve actual files (f), directories (d) and symbolic links (l) and use the sub-domain to identify the location of the user data (photos, etc).