Michdd Posted May 8, 2009 Share Posted May 8, 2009 I've been trying to figure out how to do this for a while, not constantly but here and there trying to get it to work. I've failed all times. You see it on some websites where the .php is removed from the file name. I've done some research and found that you can do this with a .htaccess file (knew this for a while now). However whenever I try it doesn't work. I'm using an apache server; I'm wondering if there is something else I have to change to get this to work? Am I putting the file in the right location? I tried putting it in my main root folder like a normal .htaccess file.. no luck.. One example of contents I've tried is: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA] Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 RewriteRule ^(.+)?\.php$ $1 [L,PT,QSA] ? Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Still not working. Seems like I must be doing something wrong or forgetting to do something; I can't find much help for this though :S Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Then yours should work fine. I guess I forgot which direction the RewriteRule's argument went. Are you saying if you go to - http://www.domain.com/file, it gives you a 404? Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Then yours should work fine. I guess I forgot which direction the RewriteRule's argument went. Are you saying if you go to - http://www.domain.com/file, it gives you a 404? Yea, that's exactly what happens. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Where did you put your .htaccess? Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 In my root folder. The same place that I normally have my .htaccess file for other stuff. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Do you have a URL I can view? Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Is it possible that I have to change a setting within my server's configuration files? Because other things that I put within my .htaccess files work fine. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 I tested the .htaccess myself and it works fine. What's the URL you're viewing? Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 I tested the .htaccess myself and it works fine. What's the URL you're viewing? http://website.com/index.php tried as http://website.com/index Edit: This server I'm just using to test stuff so it's on a port other than port 80. So could that be the problem (dunno, just trying to filter out the possibilities) Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 What's in your .htaccess file again? Sorry... there has been a bit of confusion. Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Same thing I originally posted: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA] Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Does it work on any file other than index.php? Maybe you have a directory called index? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 8, 2009 Share Posted May 8, 2009 When I do it, I do this: Options +FollowSymlinks RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /$1.php [L,QSA] Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Does it work on any file other than index.php? Maybe you have a directory called index? No I don't and it doesn't work for any files. When I do it, I do this: Options +FollowSymlinks RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /$1.php [L,QSA] That doesn't work either, again could it be that I have the port in my url?: http://domain.com:port/index Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 8, 2009 Author Share Posted May 8, 2009 Anyone have any other ideas? I still can't figure this out. 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.