Forum Moderators: phranque
I've been going in circles with this, and it's driving me insane. I've tried so many codes, some work - sort of, but not how I want it.
What I'm trying to do is take the URL example.com/domain.com and redirect it to www.example.com/verify.php?i=domain.com
The problem I am having is that, although it works, the ".com" part gets left off. I also cannot figure out how to allow it to accept http:// or ftp:// or https:// (the script will remove them).
Any help?
Thanks!
# Internally rewrite
RewriteCond $1 !^verify\.php$
RewriteRule ^([a-z0-9:\./]+)$ verify.php?i=$1 [NC,L]
Also, note that this is an internal rewrite, as it likely should be, rather than an external redirect, which upon receiving a request for a "friendly" URL send a redirect response to the client, giving it the /verify.php URL, and telling it to ask again for the resource it requested using that new URL in a new (second) HTTP request.
By contrast, an internal rewrite simply says, "If a request is received for URL "x", serve the contents from server filepath "y".
Note the distinction: An external redirect is a URL replacement requiring a second HTTP transaction between the client and the server, while an internal rewrite is a URL-to-filepath translation occuring within the context of the initial HTTP transaction. Mod_rewrite can do either, depending on the syntax of the rule you provide.
Jim
Basically, our verify.php script will verify if the domain name is registered, and if it is, it adds it to our database (the domains are owned by our clients).
The reason we want a "simple" URL is because it makes it faster for us.
Sort of like #*$!/aol.com
In reference to the http/https comment I made, I was stating that the mod_rewrite would/should accept http:// and [,...] as our verify.php script is capable of eliminating those strings before it checks.
I still haven't found a solid code. I might have to hire a pro or something.
That would be a very simple fix, and avoid all possible conflicts with other existing files or script URLs.
The problem isn't with the code, it's with designing the URLs so that mod_rewrite can reliably detect them and handle them properly without having conflicts with 'real' pages and files.
Jim