Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    htaccess question

    Hello

    I am not sure what category to put this in. I have a question about .htaccess

    what I am wanting to do is remove all .php extentions from all files on a website
    so www.domain.com/contact.php will become www.domain.com/contact

    So my .htaccess file which I have in my public_html folder is

    Code:
    RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^([^\.]+)$ $1.php [NC,L]RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    Now my issue is I am wanting to use this on a site that will not have a domain name setup with it. So the site will only be reached via a IP address like so
    http://xxx.xxx.xxx.xxx/~jjpadmin (ip address x'ed out for privacy reasons)

    and what seems to happen is when I try to go for example to

    http://xxx.xxx.xxx.xxx/~jn/contact I get a 404 error
    however when I go to
    http://xxx.xxx.xxx.xxx/~jn/contact.php the page works of course without having the .php extention removed.

    I tried putting my .htaccess on a website that I have a domain name setup/pointed to and it seems to work. So does .htaccess not work with just an IP address or how would I modify the above code so it would work when using an ip address to view a page and wanting to remove the .php extention on the files

    thanks all
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  2. #2
    Join Date
    Mar 2011
    Posts
    41
    It looks like your .htaccess file is messed up, you're duplicating the code. I just tried what you did, if you had not duplicated it, and it worked fine for me. I tried by both host and ip address without issue.

  3. #3
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791
    I must be doing something else wrong then because it does not work for me I just get a 404 error even when I correct my typo of duplicating the code which I origionally missed Doh!!

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    Is what I have and so I then try it out by going to
    http://xxx.xxx.xxx.xxx/~jn/contact

    but get a 404 unless I go to http://xxx.xxx.xxx.xxx/~jn/contact.php no 404
    Last edited by mjfroggy; 04-23-2011 at 07:14 PM.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  4. #4
    Join Date
    Mar 2011
    Posts
    41
    is there anything besides 404 in the error log? does firebug give you any other info?

  5. #5
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    ...

    Fire bug does not give any clues only shows some errors with a jquery line of code
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  6. #6
    Join Date
    Mar 2011
    Posts
    41
    do you have mod_rewrite included?

  7. #7
    Join Date
    Feb 2002
    Location
    New York
    Posts
    791

    ..

    Ya I have Mod_rewrite on which is why I can't figure out why its not workin :-(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    just a programmer

  8. #8
    I have no clue to be honest, but I am going to go out on a limb here and suggest that maybe it has something to do with the .htaccess file being used by a VirtualHost (set to your domain) while when you access the IP directly it doesn't have access to the .htaccess file.

    I'm not sure but can something be done in the httpd.conf file to allow that rewrite rule to work? Again no idea, but maybe it will trigger someone's right answer.

Similar Threads

  1. Question on .htaccess
    By hardjoko in forum Web Design and Content
    Replies: 1
    Last Post: 03-31-2010, 01:02 PM
  2. htaccess Question
    By smoosh in forum Web Hosting
    Replies: 4
    Last Post: 10-03-2007, 06:22 AM
  3. .htaccess question
    By croakingtoad in forum Hosting Security and Technology
    Replies: 11
    Last Post: 07-24-2007, 01:19 PM
  4. htaccess question...
    By theqase in forum Hosting Security and Technology
    Replies: 8
    Last Post: 07-21-2005, 05:56 PM
  5. .htaccess question
    By Cloudarama in forum Hosting Security and Technology
    Replies: 5
    Last Post: 04-18-2003, 08:33 AM

Posting Permissions

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