TapeGun007 Posted August 11, 2015 Share Posted August 11, 2015 I used to be able to type in "contacts" and it would load "contacts.php". Something in my webhost over wrote this and now I cannot get it back. I tried several examples online, but instead of opening "contacts.php" it would try to open to "contacts/". Very frustrating! Any help at getting this correct would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/ Share on other sites More sharing options...
TapeGun007 Posted August 11, 2015 Author Share Posted August 11, 2015 Never mind, I sort of figured this out. For whatever reason a file called "create_a_contact" always tries to go to a sub directory. But a filename of "create_acontact" has no issues resolving to "create_acontact.php". I'm not sure why that is. My .htaccess is as follows: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ /$1.php [L,QSA] Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518526 Share on other sites More sharing options...
requinix Posted August 11, 2015 Share Posted August 11, 2015 Well, it's like your .htaccess says: RewriteCond %{REQUEST_FILENAME} !-d"don't rewrite if the target is an existing directory". Which is a good idea to do: you probably shouldn't have a file and a directory with the same name. Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518527 Share on other sites More sharing options...
TapeGun007 Posted August 11, 2015 Author Share Posted August 11, 2015 (edited) I don't have a directory with that name. It seems that if I have a file name with two underscores in it, that it thinks it's a directory (even though one doesn't exist). So to explain better if I have http://whatever.com/who_knows_what it automatically goes to http://whatever.com/who_knows_what/ as a folder even though there is no folder with that name. Whereas, if I simply renamed it to who-knows-what and use dashes, it comes up as http://whatever.com/who-knows-what and displays the correct php file and not a directory like http://whatever.com/who-knows-what/ Edited August 11, 2015 by TapeGun007 Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518541 Share on other sites More sharing options...
requinix Posted August 11, 2015 Share Posted August 11, 2015 So you're saying that you don't have any other sort of redirection code in place anywhere, but if you go to absolutely any "file" that has two underscores in it and no trailing slash, and does not exist in any form there whatsoever, you are being redirected to the same location but with the trailing slash? So if you go to /abc_def_ghi then you get redirected to /abc/def/ghi/? Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518546 Share on other sites More sharing options...
TapeGun007 Posted August 12, 2015 Author Share Posted August 12, 2015 No. It's just like I said it is above. "abc_def_ghi" would go to "abc_def_ghi/" If I take even one underscore out, then it loads the php file as if it has the .php on the end. Strange to me. I just replaced the underscores with dashes instead and that works fine. I'm just curious as to why it does this. There is nothing else in my .htaccess except this one line: Options -Indexes to disable directory browsing. Are there any settings in php.ini that might cause this to occur? Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518557 Share on other sites More sharing options...
scootstah Posted August 18, 2015 Share Posted August 18, 2015 That's pretty strange. I would turn on RewriteLog as described here: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog This will tell you the actions that Apache is taking when rewriting. Might also be helpful to post your file structure that pertains to the URL's you're trying to access. Quote Link to comment https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1519176 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.