首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Socialengine url重写

Socialengine url重写
EN

Stack Overflow用户
提问于 2011-02-12 20:13:33
回答 2查看 2.5K关注 0票数 0

我想让用户通过键入url http://www.mysite.com/username来访问他们的页面

因此,要将http://www.mysite.com/username重定向到http://www.mysite.com/profile/username

代码语言:javascript
复制
<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On



  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]


  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]



  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]



  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]



   RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R] 


</IfModule>

为什么这个不起作用?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-09-12 16:14:34

试着把你的规则放在其他规则之前。你可以这样开始。

代码语言:javascript
复制
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R]
票数 2
EN

Stack Overflow用户

发布于 2012-09-08 02:40:59

只需注意,您可能会遇到用户与您已有的模块同名的问题。例如,如果有人将自己命名为group (出于某种原因),而您已经安装并启用了groups插件。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4977992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档