Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

How to hide the .php extension in URL ?

Hi Experts!

How to hide the .php  extension in URL ?

Thanks in advance
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

What do you hope to achieve by hiding the extension and how do you hope to format the URL without it? As Ray has suggested, there are multiple ways to do this depending on what type of server you are running and what operating system the server is running on. But the method to use really depends on the objective.
SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eduardo Fuerte

ASKER

Hi

The reason is:

After running Nibbler

They suggest

User generated image
Linux/ Apache/ PHP5
No user remembers the URL to go to a specific page, the complexity that is introduced by such suggestions in my opinion is not worth the effort.
Having a good site content, search option of your site, ...

Do you use a content management system such as Wordpress, Drupal, Jumla, etc?
Hi

I don't use Wordpress, etc...

A reasonable alternative is to use Codeigniter, since I had been using it in another project.
i am unfamiliar with either the assessing site nor codeigniter.
Are the three references including in the reason something you are concerned with to undertake?
Arnold

By using Codeigniter the URL's file extension is ommited. Just this.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Eduardo,
You can do this, using Apache Mod_Rewrite.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

What you need to do, is in your virtual host, or .htaccess file, or whatever your using.

Turn rewrite engine on, and create a rewrite rule.

RewriteEngine on
RewriteRule ^([^\.]+)$ /folder/$1.php [NC,L] 

Open in new window


With that being said, I agree with Dave, that this might be less then optimal, and could cause a lot of work for you depending on your implementation, subdomains, etc..

It might be better to just accept the nibbler complaint and ignore it, unless you have a really good business reason to do otherwise.
After reading what you posted and suggested.

I concluded it's unnecessary and don't pay the work to be spended.

Thnak you.
Sorry, Chris

Your last reply went the same time I was closing the question.
Our conclusions are coincident.
Just to note: Nibbler tells the reasoning behind that I won't repeat.

SEO friendly rewritten URLs have many positive effects in easier to redirect URLs. You might change your underlying architecture with same links still valid, only rewritten in other ways.
Search engines consider such URLs better and rank you higher.

In the end it is worth considering URL rewrites, but it's not a first thing to address indeed. But not having in mind a URL schema you could apply later you'll have it even harder to invent one that works, when you go back to this task. So it's worth noting and learning how this works and what it can do for you.

Simple URL schemas are something like

www.domain.com/language/topic/detail/param1/param2
eg
www.domain.com/en/products/software/SKUno1/
and rewritten as
www.domain.com/index.php?language=en&topic=products&category=software&productid=SKUNo1
You often enough will have many rules , eg links having products as topic have other parameter names as other topics, so rules could check for a certain name and call other php files.

It might help later to have a php script specific to products so URLs about product info is rewritten as
www.domain.com/products.php?language=en&category=software&productid=SKUNo1, still the url is
www.domain.com/en/products/software/SKUno1/

Then you also have the chance to use many different url schemas and rewrite rules by using subdomains like api.domain.com for developer apis img1.domain.com, img2.domain.com  for serving images etc etc.

It's really worth having that in mind and designing your site with this in your mindset, even if you for now don't want to handle regular expressions. Those, in the end, can also be generated by tools I already pointed out. So this is not the barrier.

Bye, Olaf.