hey guys, i was wondering, is there any other way to hide .php extensions without using .htaccess?

Instead of:
http://www.example.com/index.php
Visitors to your site will see:
http://www.example.com/index/

my webhost does not support the .htaccess thingy. :yawn: :@

Recommended Answers

All 6 Replies

Make a directory named index and place an index.php there.
Probably the configuration of your server needs an index.php in the root, you can place an header redirect in this file:

<?php header("Location: /index/",TRUE,301); ?>

So your structure will be:
/index.php
/index/
/index/index.php

bye

Make a directory named index and place an index.php there.
Probably the configuration of your server needs an index.php in the root, you can place an header redirect in this file:

<?php header("Location: /index/",TRUE,301); ?>

So your structure will be:
/index.php
/index/
/index/index.php

bye

Thanks for the reply, so i do that for all pages?

Yes. If you have contact.php make /contact/index.php, and so on, this will give you the ability to write http://www.your_server.tld/contact/

And for a while you can set an header redirect on the original files, just like in root index.php, so the spiders will save the new position.

If your webhost does not support .htaccess and the web server is Apache...move to a better host.
If your webhost does not support .htaccess and the web server is not Apache, look to see what type of url rewriting it supports. If you still can't...move to a better host.

.htaccess or its equivalent is pretty much an industry standard these days.

Creating tons of index.php files in tons of nested directories, not only introduces a maintenance nightmare, but also introduces a security risk when it comes to fixing bugs they will need to be pushed through any file with duplicated code. This goes back to creating a maintenance nightmare.

As far as i know, some servers trigger .htaccess when you ask them, instead of automatically, you could try asking them, or... move to another host :)
(i'm sorry, were there supposed to be quotation marks there?)

anyway, if all else fails, you could just make 1 page with a big frame, and have all links change the content of the frame and what the user sees on the top remains the same.

Frames are hardly an ideal solution, but the same goes for not having .htaccess support

hello am trying to hide file extensions in my website, immediately i add a .htaccess they site just cant proceed from the login page to the dashboard. how can i hide the file extensions without much trouble

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.