Treehouse: Grow your CSS skills. Land your dream job.

no access if .php

  • # June 24, 2013 at 3:24 pm

    Hello again, i want to make that, if the user type in the url bare, that .php shows an error or maybe an images, and if it is it shows the real page. I wan’t this because i don’t want the .htaccess to make to names for the same site.

    i have this in my .htaccess file.

    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    This change the to

    Thanks in advance :-D

    # June 24, 2013 at 3:28 pm

    If they type in ``, wouldn’t the `.php` end up being removed because of the htaccess?

    # June 24, 2013 at 3:35 pm

    you are right, but is there a way where i only can show the and the same if people type ind in the url bar? :D

    # June 24, 2013 at 3:54 pm

    That’s my point. The user should never see the `.php` extension. Even if they type it in, it will be `index` but still show the data from `index.php`

    # June 24, 2013 at 4:02 pm

    that’s exactly what i would have the .htaccess to do, if it’s possible ;-)

    # June 24, 2013 at 4:09 pm

    That’s not what is happening from the htaccess code I gave you in your other post? Can we see a live link?

    # June 24, 2013 at 4:22 pm

    Right now i test it in localhost, but if the user in the url bar type .php after the /index then they come to the same page, but i don’t think it’s a problem. The only thing i don’t understand is why the .htaccess makes something like 2 pages for every page. One with .php and one with out, but you need to type in .php before it shows? :-D

    # June 24, 2013 at 4:24 pm

    Do you have mod rewrite allowed in Apache?

    # June 24, 2013 at 4:33 pm

    hmm, do you know where i can check that ? :D

    # June 24, 2013 at 4:38 pm

    + Left click on the `W` icon of Wamp
    + Hover `Apache`
    + `Apache Modules`
    + Scroll down till you see `rewrite_modules`, is it checked? If not, click on it.

    # June 24, 2013 at 4:49 pm

    it seems to work now, thanks for your help and your time ;)

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.