How can i hide the .extension file in url?
Results 1 to 6 of 6

Thread: How can i hide the .extension file in url?

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    33

    How can i hide the .extension file in url?

    hello,

    I want to hide the extension file in address bar.

    Example: www.aaa.com/index.php and it should be like this www.aaa.com/index

    Please let me know anyone waiting for ur response..

    This is my .htaccess file in website

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME}\.php -f

    RewriteRule ^(.*)$ $1.php






    regards,
    simbu.
    Last edited by simbu; 11-14-2012 at 01:07 AM.

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,414
    One way:
    Code:
    Options +MultiViews
    See MultiViews in the Apache docs for more info on what that does.

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    33
    Quote Originally Posted by bradgrafelman View Post
    One way:
    Code:
    Options +MultiViews
    See MultiViews in the Apache docs for more info on what that does.
    Now there is no change in my url.I am getting with .php or .html extensions.

    Could somebody tell me whats the problem?



    regards,
    simbu.

  4. #4
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Write the URL without the file extension.

    .htaccess can help find the file when you leave the extension off, but only the user can decide what to write in the address bar.

    Likewise, change all your links to omit the file extension.

  5. #5
    Senior Member
    Join Date
    Apr 2003
    Location
    Silver Lake
    Posts
    4,851
    If you type in a particular url and your server is configured to respond to that url without redirecting, then the url is going to stay unchanged.

    If you want a request to that url to redirect the user somewhere else, you'll need to either alter index.php to redirect the user:
    PHP Code:
    header("location index");
    exit; 
    Or you'll need to set up some appropriate mod_rewrite directive. Offhand, I don't know what that would look like.
    IMPORTANT: STOP using the mysql extension. Use mysqli or pdo instead.
    World War One happened 100 years ago. Visit Old Grey Horror for the agony and irony.

  6. #6
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,697
    You can also using Apache type directives (like ForceType) to force a file without an extension to be parsed as, say, PHP.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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