Jump to content

Php Not Working In Code When Removing File Extension


Recommended Posts

SOLVED.

 

I'm hosted at hostgator, but I hope I can get some help here.

So some of the design on my page is being directed there by php.

&--#60;?php include_once("templateDesign.php"); ?&--#62;

I wanted to remove the file extensions, so you could just type mysite.com/example and the .php extension wouldn't come up. I did this by using this code in my htaccess file:

# Apache Rewrite Rules

&--#60;IfModule mod_rewrite.c&--#62;

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

 

 

# Remove .php-extension from url

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^([^\.]+)/$ $1.php

 

# End of Apache Rewrite Rules

&--#60;/IfModule&--#62;

Now, the problem is it isn't loading the content from the .php correctly. Just some come up, indicating that it reaches the .php file with content, but doesn't load it correctly.

Link to comment
Share on other sites

Go ahead and create your file with a .php extension and then add this to the .htaccess:

 

Options +MultiViews

 

Then you can remove the .php from the url like this:

 

http://bybyron.net/test/hello_world

 

or

 

http://bybyron.net/test/hello_world.php

 

Also work for image files.

 

This is how it works here at heliohost. Not sure about HostGator.

Link to comment
Share on other sites

Go ahead and create your file with a .php extension and then add this to the .htaccess:
Options +MultiViews

Then you can remove the .php from the url like this: http://bybyron.net/test/hello_world or http://bybyron.net/test/hello_world.php Also work for image files. This is how it works here at heliohost. Not sure about HostGator.

 

Thanks a ton, that worked :D

Link to comment
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.   Paste as plain text instead

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