sin Posted December 5, 2007 Share Posted December 5, 2007 hi guys, I've cooked my brain for the last 48 hrs trying to figure out what the results of my internet search say (I used the search terms "hide php extensions") but didn't make it...... sorry if the answer to my question is somewhere in this forum and I'm too much of a newbie to see it!!! Here's what I'm after: Can the following simple request: <a href="page.php">page</a> produce the following URL: http://www.mydomain.com/page just before I quit (10 minutes ago...) I thought that writing something "smart" in a .htaccess file would do it..... tested several "smart" things but none worked........ Thanks, Sin Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/ Share on other sites More sharing options...
sin Posted December 6, 2007 Author Share Posted December 6, 2007 ...sorry for the confusing tags in the initial message In simple terms, can I type www.whateversite.com/page in a browser and, through a .htaccess file, get the file page.php on the screen?????? Thanks, Sin Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-408261 Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-408333 Share on other sites More sharing options...
sin Posted December 7, 2007 Author Share Posted December 7, 2007 thanks for taking the time to help but I still get a 404... I copied your code below in a .htaccess file and uploaded it in the same directory where I have the .php file..... Typing the url without the .php after the name of the file gives me the 404 Error. I'm probably doing wrong something very basic so thanks for your patience in advance....... Ideas??? Sin Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-409124 Share on other sites More sharing options...
sin Posted December 23, 2007 Author Share Posted December 23, 2007 I reviewed the entire mod_rewrite forum and I didn't manage to solve my problem However, I discovered that a lot of people post queries without sufficiently studying the issue; obviously I did the same so pls accept my sincere apologies. In order to redeem myself I spent a couple of hours reading tutorials and I now know the exact meaning of every single command of my .htaccess file (kindly provided by thorpe): RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L] If I type domain/test, I should be getting domain/test.php, right? Well, here's what happens: 1. If I type domain/test, I get an Error 404 (file test.php is definetely in the same directory as the .htaccess file) 2. If I type domain/ and then ANYTHING, I get an Error 500! My web host, 1and1, does not allow access to error logs so I haven't got a clue what to do. For the record, I tried the Bob/Alice example from this link http://www.workingwith.me.uk/articles/scripting/mod_rewrite and it worked :-\ so I guess the basics of the module are OK. Heeeeeelp...... Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-421763 Share on other sites More sharing options...
sin Posted December 27, 2007 Author Share Posted December 27, 2007 ...and some more testing results: Using: RewriteRule ^(.+)\.abc$ $1.php [L] I can type /anything.abc and I get /anything.php Using: RewriteRule ^(.+)\.$ $1.php [L] I can type /anything. and I get /anything.php One step further using: RewriteRule ^(.+)$ $1.php [L] I get an Error 404... ??? it must be something totally stupid, the rewriting seems to work fine. Ideas??? Thanks, Sin Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-424113 Share on other sites More sharing options...
sin Posted January 7, 2008 Author Share Posted January 7, 2008 ...added Options -MultiViews and it works fine!!! Unless someone has any comments, I'll mark this post as solved within the next couple of days later, sin Quote Link to comment https://forums.phpfreaks.com/topic/80328-solved-hiding-php-extensions/#findComment-432812 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.