Page 1 of 1

Error 404 URL Redirection

Posted: Tue Mar 31, 2009 5:33 pm
by strangledspyder
I bet this involves .htaccess more than php but I wasn't sure so I am posting here anyway.

I am trying to get a url with a random string at the end to redirect to a specific php page with the string appended as a GET variable. For example:

http://www.whatever.com/Google

Becomes

http://www.whatever.com/redirect.php?q=Google

But

http://www.whatever.com/

Goes to the index.php file.

Any help would be much appreciated.

Re: Error 404 URL Redirection

Posted: Tue Mar 31, 2009 8:15 pm
by requinix
Yep, .htaccess.

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* redirect.php?q=$0

Re: Error 404 URL Redirection

Posted: Tue Mar 31, 2009 8:27 pm
by strangledspyder
Thanks. I ended up using the following and it seems to work for what I want:

RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)$ /redirect.php?site=$1