...

View Full Version : Can't hide .php with .htaccess



Neet
06-09-2011, 04:01 PM
I have checked and mod_rewrite is on


Loaded Modules core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_include mod_filter mod_log_config mod_env mod_expires mod_headers mod_setenvif mod_version prefork http_core mod_mime mod_status mod_autoindex mod_asis mod_info mod_vhost_alias mod_negotiation mod_dir mod_actions mod_alias mod_rewrite mod_so mod_php5 mod_ruid2

This is what I have in my .htaccess

Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ $1.php

I can't get it to work for some reason.

#Note mysite isn't really my web site

I want www.mysite.com/dog.php to also work when I go to www.mysite.com/dog

When I put in the codes only www.mysite.com/dog.php works and with www.mysite.com/dog nothing happens.

MarPlo
06-09-2011, 05:23 PM
Hy,
Try this code:


Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mysite.com/([0-9a-z_-]+)$ mysite.com/$1.php [NC,L]

Neet
06-09-2011, 06:35 PM
Hy,
Try this code:


Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mysite.com/([0-9a-z_-]+)$ mysite.com/$1.php [NC,L]


Thanks for your help, but the same thing happens. Nothing happens and I did replace mysite.com with my real website.

mysist.com/dog.php works while mysite.com/dog doesn't.

Fou-Lu
06-09-2011, 10:19 PM
What is .apache? Do you mean httpd.conf or .htaccess?
If its httpd.conf where you made changes, you will need to restart the apache service or daemon before the changes take place.

Neet
06-09-2011, 10:31 PM
What is .apache? Do you mean httpd.conf or .htaccess?
If its httpd.conf where you made changes, you will need to restart the apache service or daemon before the changes take place.

I feel silly I mean .htaccess I have no idea where that apeache came from. I have tried so many things I'm starting to believe the problem lies with my host (000webhost). This is a small project of mines so I'm using a free host for now.

Neet
06-09-2011, 10:40 PM
Ok I feel really silly now, I found my problem. 000webhost uses user home directory paths so I ended up getting errors when trying to set up RewriteRule's. All I needed to fix this issue is add RewriteBase / to the very top of my .htaccess file.

Oh well at least in a few years someone will end up having the same problem as me. Hopefully they find this thread.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum