.htaccess finding file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

.htaccess finding file

Post by JustinMs66 »

right now i am using http://ip.goes.here/~admin/ to view my website until i switch dns over this new server. http://ip.goes.here/~admin/ points to /home/admin/public_html/.

I have an .htaccess in /home/admin/public_html/ saying:

Code: Select all

RewriteEngine On
allow from all
RewriteRule ^contact$ contact.php
when i go to http://ip.goes.here/~admin/contact.php, it works, but when i go to http://ip.goes.here/~admin/contact, it says:
404: The requested URL /home/admin/public_html/contact.php was not found on this server.
however, i checked it with SSH, and that file does exist.

so .htaccess is looking in the wrong place. is this because of the extra directory /~admin/ in the url i have to use until i switch, is it screwing things up?
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: .htaccess finding file

Post by Darhazer »

This can be resolved in this way:

Code: Select all

RewriteCond %{REQUEST_URI} ^(.*)/contact$
RewriteRule ^contact$ %1/contact.php
Post Reply