Jump to content

.htaccess


TapeGun007

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518526
Share on other sites

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/

Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518541
Share on other sites

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/?

Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518546
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1518557
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/297742-htaccess/#findComment-1519176
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.