我想让用户通过键入url http://www.mysite.com/username来访问他们的页面
因此,要将http://www.mysite.com/username重定向到http://www.mysite.com/profile/username
<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>为什么这个不起作用?
发布于 2011-09-12 16:14:34
试着把你的规则放在其他规则之前。你可以这样开始。
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R]发布于 2012-09-08 02:40:59
只需注意,您可能会遇到用户与您已有的模块同名的问题。例如,如果有人将自己命名为group (出于某种原因),而您已经安装并启用了groups插件。
https://stackoverflow.com/questions/4977992
复制相似问题