Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't hide .php with .htaccess

    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.
    Last edited by Neet; 06-09-2011 at 09:29 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2011
    Posts
    148
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Hy,
    Try this code:
    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]

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MarPlo View Post
    Hy,
    Try this code:
    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.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    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.

  • #6
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by Neet; 06-09-2011 at 09:43 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •