Hi,
I'm need of rewriting urls that a user may browse to (which would be a invalud url), and rewrite the url to a valid url.
for instance a user may browse to :
http://www.alljammin.com/my_username
and thr url should be rewritten to maybe
http://www.alljammin.com/php/profiles.p ... y_username
my_username would be a user defined name, so it could be anything.
Im completely new to url rewriting, and regular expressions, so all your help will be greatly appreciated.
Kind Regards
Musaffar
PS, I'm hosting on a Apache webserver
URL Rewriting
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
viewtopic.php?t=28701 has several details pertaining to this. In fact, everything involving mod_rewrite in the thread (sans spelling errors) works toward your "issue".. you will have to incorporate several of the posted bits together to achieve it, but the information is all there.
Hey mzfp2,
I know how hard it is to understand mod_rewrite, it took me days to read up on it and I STILL wasn't able to write a basic redirect that worked
Unless you are going to use mod_rewrite for lots of stuff, there's no point studying it, as it's very complicated.
You asked for the most basic redirect, here it is:
It checks for existing files and folders, then stops if it found one, if not it redirects. If you want to know how it works, or need to tweek it, you will still have to get back to the books 
Also try this site:
http://www.modrewrite.com
While studying mod_rewrite I mostly found others with the same question. I hope this snippet will free the real gurus from answering this basic question.
I know how hard it is to understand mod_rewrite, it took me days to read up on it and I STILL wasn't able to write a basic redirect that worked
Unless you are going to use mod_rewrite for lots of stuff, there's no point studying it, as it's very complicated.
You asked for the most basic redirect, here it is:
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f їOR]
RewriteCond %{REQUEST_FILENAME} -l їOR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - їL]
RewriteRule ^(їa-z0-9]+)/? profiles/?id=$1 їL]Also try this site:
http://www.modrewrite.com
While studying mod_rewrite I mostly found others with the same question. I hope this snippet will free the real gurus from answering this basic question.