Jump to content

Remove .php from url


frshjb373

Recommended Posts

I want to remove .php extension from all my urls. I've tried a ton of htaccess codes that I found on the web, but nothing seems to work.  Isn't there a way to refer to a page within your site simply by naming the file name without the extension?  For example, I currently have:

<a href="birds.php">Birds</a>

  But how do I make something like the following work?

<a href="birds">Birds</a>

or

<a href="/birds">Birds</a>

  Any help would be much appreciated.  Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/266952-remove-php-from-url/
Share on other sites

Unfortunately that did not work.  Should I be referring to my pages in the code without the .php or use a slash in front of the page?

 

Also, the rule you provided broke my redirect code:

 

RewriteEngine on
<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 404 /404.php

RewriteCond %{HTTP_HOST} ^joytothewild\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.joytothewild\.com$
RewriteRule ^(.*)$ "http\:\/\/www\.joytothewildphotos\.com\/$1" [R=301,L]

 

Any other ideas?  Also, thank you for the help.

Link to comment
https://forums.phpfreaks.com/topic/266952-remove-php-from-url/#findComment-1368647
Share on other sites

Paste what you've done because you've got a redirect in there with a last option.

 

Moreover, you've got unnecessary stuff in that file.

 

RewriteCond %{HTTP_HOST} ^(www\.)?joytothewild\.com$
RewriteRule ^(.*)$ "http\:\/\/www\.joytothewildphotos\.com\/$1" [R=301,L]

 

I'm not really sure what the deal with <Files> is but it looks like your denying the use of any htaccess files....

Link to comment
https://forums.phpfreaks.com/topic/266952-remove-php-from-url/#findComment-1368655
Share on other sites

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.