0

Hi.
I've been working on this for maybe 10 hours without success and hope someone can help me here.

Sounds simple:

I want the user to enter URLs similar to this:
www.site.com/thisuser
or
www.site.com/thisuser/
(never underestimate the stupidity of the user, so I want it to work with or without the last slash)

The folder /thisuser/ (or whatever else is entered) does not exist.

This should redirect the user to:
www.site.com/users/index.php?id=thisuser

And for some reason I can't get it to work. All I get is either Firefox or Error 500 telling me about redirecting loops.

I keep seeing this version here that should work, but for some stupid reason it just won't for me:

#Options +FollowSymlinks
Options +FollowSymLinks -MultiViews
# // found -MultiViews somewhere and tried it without success
RewriteEngine on

#RewriteCond %{SCRIPT_FILENAME} !-f
#RewriteCond %{SCRIPT_FILENAME} !-d
# // for testing purposes, I simply disabled these for now to make sure it is the next line that does the work:

RewriteRule ^([^/]+)/?$ /testredirect.php?$1 [QSA,L]

# //used /testredirect.php for now to see if it would work - tried /test/$1 before, also without success

According to one or two different forum posts I found, this should be exactly the code I want.

Why does it create these loops?

Any idea on what I can do?

Thanks so much in advance!

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Member 785748
0

Hi, thanks for the reply.

The .htaccess file is in the root folder, if that is what you're asking.

Where should the full URL go?

Here?

RewriteRule ^([^/]+)/?$ http://testsrv/testredirect.php?$1 [QSA,L]

(I'm running it on my test server right now in case there's any confusion about the "domain").

0

Yes, there.

But if you put it in your main folder, then the rewrite rule matches /testredirect.php aswell, won't it ?;)

0

Ah, good point...
So I need to exclude that file (or later on folder) from that...

So, would this do the trick (if added before the other code)?

RewriteRule ^(testredirect.php)(/.*)?$ - [L]
0

Never mind, I just tried it, and it seems to work!!!!!!!!

W00h00!!! :-)

Thanks so much!

Ah, good point...
So I need to exclude that file (or later on folder) from that...

So, would this do the trick (if added before the other code)?

RewriteRule ^(testredirect.php)(/.*)?$ - [L]
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.