removing .php giving a 404
- Started
- Last post
- 8 Responses
- utf8
Designer here who knows just enough to break stuff. I have a subdomain dev.name.co located at /dev. I want my urls to look like http://dev.name.co/about
I have an .htaccess file in /dev with the following code.<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule><IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>In /dev I have an "about page" named "about.php". I have a navigation item linked to
<a href="/about">about</a>
When I click the "about link" I get an 404 saying "The requested URL /dev/about.php was not found on this server." I know nothing about configuring a .htaccess. What am I doing wrong?
- vaxorcist0
if you do the multi-folder index.php code thing, you may accidently write one index.php over annother ... ooops...
I would try:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
- vaxorcist0
you may need:
Options +FollowSymlinks
- fugged0
@vaxorcist - yeah, it does require a bit of discipline so you don't overwrite or confuse files. But, IMO, it's a better alternative from an organizational standpoint. To each his own though...
- vaxorcist0
yes, and the multi-folder index.php method is easy to move servers with....
- utf80
Thanks for the responses. I went and used the folder > index,php route. Now since all my pages are longer in the root but in their own folders I had to use relative links for the includes, images, and css. Then on the index.php which lives in the root I had to use root relative for includes, images, and css. You guys got any tricks to make it consistent for all pages?
- fugged0
Rather than try and explain options, here's a page with ways you can handle includes/paths: http://www.geeksengine.com/artic…
I suggest setting an include path that is _outside_ of your web root. That way these PHP files can't get called directly from a request. If you have database credentials in any of your php files, you will want to do this.
Again - just my opinion, and how I like to work... :)