Jump to content

[SOLVED] Removing the extension..


Michdd

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/157314-solved-removing-the-extension/
Share on other sites

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)

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

 

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.