Hi, I'm not sure how to do this... Whether index.php can handle it or if I need to use mod rewrite? Any advice and/or examples greatly appreciated. I have a multi-user blog, lets say there if Fred, Peter and Jane I want them to have their own page, eg: blog.domain.com/fred blog.domain.com/peter blog.domain.com/jane I do NOT want to create subfolders for each user. The above should effectively be the same as: blog.domain.com/index.php?blog=fred blog.domain.com/index.php?blog=peter blog.domain.com/index.php?blog=jane Any easy way to do the shorter method?
RewriteEngine On RewriteRule ^([^/]+)$ index.php?blog=$1 Code (markup): Save this as .htaccess in your main directory.
doesn't work My index.php contains a 'coming soon' image. After I put that in my .htaccess, the index.php loads but the link to the image is broken. ?
Sorry, forget last comment... I pasted this into my index.php to test: <?php if ($_GET["blog"]!="") { echo $_GET["blog"]; } ?> It displays value 'index.php', not fred
Ah yes, my bad. Try this. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule index.php?blog=$1 [QSA] Code (markup): Modified from this post. http://forums.digitalpoint.com/showpost.php?p=4644006&postcount=7
Still not working If i type blog.domain.com/fred I get a 404 error. It seems its trying to load fred.html Thanks for your efforts btw. I'm having fun trying.
I'm soooooo close! A the moment I have: RewriteEngine on RewriteRule ^([A-Z]+)/?$ index.php?blog=$1 [NC,QSA,L] If I type: blog.domain.com/fred blog.domain.com/peter it works fine. If I type: blog.domain.com/fred1 blog.domain.com/peter parker It fails. I suppose I need to change the A-Z bit to inc numbers and other characters?
Last post from me. Got it working, sort of. RewriteEngine on RewriteRule ^([A-Za-z0-9]+)/?$ index.php?blog=$1 [NC,QSA,L] It accepts usernames without spaces or symbols, ie. letters of the alphabet and number 0 to 9. Good enough for me. Thanks for your input nico_swd
try RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?blog=$1 [L,QSA] Code (markup):