Jump to content
Sign in to follow this  
TapeGun007

.htaccess

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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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/

Edited by TapeGun007

Share this post


Link to post
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/?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • 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.