Forum Moderators: phranque
I'm looking at getting variables which use dots within them, such as; "example.com/path.example/domain.com/user.range"
How would I go about building a htaccess file using mod_rewrite which will help me interpret this. Even if this is only one large string that is fine but I'd like it to after reading this to go to: "example.com/find.php?=path.example/domain.com/user.range".
Right now my server thinks this is a file and wont even try loading, I don't always know though what will be in url.. as to how many dots at least.
Thanks
Brandon
It returns a 302 redirect because you used [R] without a number. Redirects should be 301, and the redirect code should also contain the target domain name. You probably do not need a redirect here, though.
What you likely need here is a rewrite. In that case, change one thing in your original code... change [R] to just [L] instead.
Next up, you need to define exactly the format for URLs used on the web, and the format of the parameters used with the file on the server. Once that is done, the actual coding part becomes trivial.
There's a bunch of stuff in a recent thread that might be useful... [webmasterworld.com...]
See I don't acually know the url that may be sent so I need it to be able to accept anything after the example.com/ and then place it in index.php?find= without trying to see if its a file or directory.
Is that even possible?
In this case you need a rewrite, not a redirect, so omit the domain name and the [R] so that the target is a file inside the server, not a new URL out on the web.
That's the difference between a rewrite and a redirect.
# If request has not already been rewritten to /index.php
RewriteCond $1 !^index\.php$
# and if request does not resolve to an existing file
RewriteCond %{REQUEST_FILENAME} !-f
# and if request does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# then rewrite the request to /index.php
RewriteRule ^(.*)$ /index.php [L]
Jim