You are not logged in.
Pages: 1
Topic closed
hey all,
i have this problem, i know it will sound silly but it has been baffling me all day,
i am building what my boss calls "engine", which is primarly a single script with a different database for each user, the problem is that i need him to be redirected via the URL.
example:
if the user types www.mycompany.com/username
he should be redirected to www.mycompany.com/index.php?name=username
i have been playing all day with the file but nothing seems to work,
here is some of the code i've used so far,
RewriteRule ^test/([a-z0-9]+) http://www.myweb.com/test/index.php?name=$1 [PT]
RewriteRule (.*) /index.php?name=$1 [PT]
RewriteRule (.*) test/index.php?name=$1
any help.. anyone?
Last edited by Asharif (July 26 2010)
Try this:
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?name=$1 [L]
Thats the most basic use of mod_rewrite, there should be plenty of examples on google...
mod_rewrite is a pain to debug though, you need to build it very gradually and do
<pre>
<?php print_r($_GET) ?>
</pre>
in the PHP to better see what is happening.
There's a way to debug it but I never used it myself I think it's not very user-friendly.
EDIT: Start without the ^ at the beginning and with something very generic like (.*) to see the result in the php print_r, and build from there.
Last edited by rolf (July 26 2010)
Here is the code that eventually worked:
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?test=$1 [L]
thanks everyone :)
Here is the code that eventually worked:
RewriteEngine on RewriteRule ^([^/\.]+)/?$ index.php?test=$1 [L]
thanks everyone :)
You're welcome.
Always remember to turn the RewriteEngine on.
Pages: 1
Topic closed