Socialengine url rewriting
I want to let users access their pages by typing the url http://www.mysite.com/username
So to redirect http://www.mysite.com/username TO 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_FILEN开发者_JS百科AME} !-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>
Why wont this work?
Try putting your rule before the other rules. You can start this way.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z_-]+)$ /profile/$1 [R]
Just note of caution that you might run into an issue of a user has the same name as module you already have. For instance if someone named themselves group (for some reason or another) and you have the groups plugin installed and enabled.
精彩评论