Jump to content

[SOLVED] hiding php extensions...


sin

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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