Helmet Posted January 4, 2009 Share Posted January 4, 2009 After a couple of hours of looking for a solution and trying different rules, I've come to the conclusion that there's something outside of mod_rewrite causing this problem. I thought I'd found the solution when someone in another thread was talking about turning off multiviews, but I've done that to no avail. If it matters, I'm with 1&1. I'm looking to change: http://example.com/variable-directory-name/file.php?id=integer to http://example.com/variable-directory-name/file/integer/ and I'm trying to use this to do it: Options -MultiViews +FollowSymLinks RewriteEngine on RewriteRule ^(.*)/file/(.*)/$ $1/file.php?id=$2 [L] But all I get is: Multiple Choices The document name you requested (/variable-directory-name/file/integer/) could not be found on this server. However, we found documents with names similar to the one you requested. Available documents: /variable-directory-name/file.php/integer/ (common basename) The closest I've come to solving this is determining that my mod_rewrite rules seem to be good, because if I'm not getting this I'm getting a 404. Am I missing something simple? Ideally I'd like to be able to place this rewrite in the site's root .htaccess. Quote Link to comment Share on other sites More sharing options...
corbin Posted January 4, 2009 Share Posted January 4, 2009 variable-directory-name does exist, yes? Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 Yep.. for now I'm trying to do this in an htaccess in one of those directories: http://example.com/variable-directory-name/.htaccess ??? Quote Link to comment Share on other sites More sharing options...
corbin Posted January 4, 2009 Share Posted January 4, 2009 Try changing RewriteRule ^(.*)/file/(.*)/$ $1/file.php?id=$2 [L] to RewriteRule ^(.*)/file/(.*)/$ /$1/file.php?id=$2 [L] Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 No joy, unfortunately. Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 Or you can try this: Options +FollowSymLinks RewriteEngine on RewriteRule file/id/(.*)/ file.php?id=$1 RewriteRule file/id/(.*) file.php?id=$1 This will make your url: http://www.example.com/variable-directory-name/file/id/integer/ Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 @bubbasheeko: I tried that, and if I add id to the url, I get a 404: http://example.com/variable-directory-name/file/id/integer/ but if I leave the url without id, I still get the same multiple choices. Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 Sorry, I didn't see that arrangement in this thread. It would have to be something outside of mod_rewrite. What I provided was all you should need. What is producing the error, your host or your code? Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 It's an Apache 300 error code. Something is interacting in an unsavoury way with mod_rewrite Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 Let's see what is in your .htaccess file. Let's start from the beginning Another thing I just thought of and I am not sure if you tried it yet. Add this before the Rewrite: Options +MultiViews Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 Ok, I appreciate your help! I have one htaccess at the root of the site: #password for dev environment AuthType Basic AuthName "directory" AuthUserFile /path/to/htpasswd require user helmet RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /errordocument.php and then there's the htaccess in question in one of those second level directories http://example.com/directory/.htaccess. Options -MultiViews +FollowSymLinks RewriteEngine on RewriteRule ^(.*)/file/(.*)/$ $1/file.php?id=$2 [L] I'm trying to build http://example.com/directory/file/integer/ from http://example.com/directory/file.php?id=integer I'm not sure if there's any other information that would be helpful... Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 That's good. Now eliminate the second .htaccess. Two, the .htaccess file on the root has rewrite rules, but you will notice that it is not turned on. So let's rewrite it, pardon the pun. #password for dev environment AuthType Basic AuthName "directory" AuthUserFile /path/to/htpasswd require user helmet Options -MultiViews +FollowSymLinks RewriteEngine on RewriteRule file/id/(.*)/ file.php?id=$1 RewriteRule file/id/(.*) file.php?id=$1 If you experience the same thing - switch the -MultiViews to +MultiViews. I also took out RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /errordocument.php Just for now. Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 ok, example.com/.htaccess is now: AuthType Basic AuthName "directory" AuthUserFile /path/to/htpasswd require user helmet Options -MultiViews +FollowSymLinks RewriteEngine on RewriteRule file/id/(.*)/ file.php?id=$1 RewriteRule file/id/(.*) file.php?id=$1 I get the same 300 for example.com/directory/file/integer/ and a 404 if I change to +MultiViews incidentally, the errordocument.php lines were working as expected despite not having the line turning the engine on Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 What about with +MultiViews? Quote Link to comment Share on other sites More sharing options...
Helmet Posted January 4, 2009 Author Share Posted January 4, 2009 404 Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted January 4, 2009 Share Posted January 4, 2009 Time to pick the brain of the host techs Quote Link to comment Share on other sites More sharing options...
Helmet Posted February 14, 2009 Author Share Posted February 14, 2009 Hey B, just to let you know, I switched my hosting away from 1&1 to HostGator and now all kinds of things are working as they should. Your advice was spot-on, thanks for your help on this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.