Redirecting every call that does not have a certain string in it
am 03.08.2007 12:25:51 von damezumari
I have a page that could be called like this:
http://iwyq.com/index.php?user=elvis
http://iwyq.com/index.php?user=doris
http://iwyq.com/index.php?user=john
but it would be simpler for the user if instead it could be called
like this:
http://iwyq.com/elvis
http://iwyq.com/doris
http://iwyq.com/john
To achieve this I have been told I may use a .htaccess file in the
root folder of http://iwyq.
This is my best attempt so far:
RewriteEngine On
RewriteCond %{REQUEST_URI} !.php
RewriteRule ^(.*)$ http://iwyq.com/index.php?user=$1 [L,R]
The idea is that the only calls that do not include the string '.php'
are the ones that shall be redirected.
Can someone please correct the code for me?
Regards,
Jan Nordgreen
Re: Redirecting every call that does not have a certain string in it
am 03.08.2007 16:23:29 von dvader
> I have a page that could be called like this:
> http://iwyq.com/index.php?user=elvis
> http://iwyq.com/index.php?user=doris
> http://iwyq.com/index.php?user=john
> but it would be simpler for the user if instead it could be called
> like this:
> http://iwyq.com/elvis
> http://iwyq.com/doris
> http://iwyq.com/john
I don't know if you can redirect to a file like that with htaccess or an alias,
I'm new to Apache myself, but a simple way to achieve the same effect would be
to create directories for each variable.
DocumentRoot/elvis/index.php?user=elvis
DocumentRoot/doris/index.php?user=doris
DocumentRoot/john/index.php?user=john
This assumes that index.php is one of your default files, of course.
In the meantime, I'll see if I can come up with a better solution. It is a good
Learning Experience. :-)
--
Crash
Please reply to the group. E-mail is blocked.
Re: Redirecting every call that does not have a certain string in it
am 03.08.2007 18:45:02 von damezumari
Thanks for the answer Crash!
I agree that I can create folders, but I rather use .htaccess.
A friend of mine, found a solution:
RewriteEngine on
RewriteBase /
# Rewrites myserver.com/USERNAME to myserver.com/index.php?
user=USERNAME
RewriteRule ^([^/\.]+)/?$ /index.php?user=$1
And, it works! :)
Regards,
Jan Nordgreen