Results 1 to 13 of 13
  1. #1

    Delete "index.php" from the URL

    Hi,

    Does somebody know how to delete the "index.php" in from the URL pointing to the home page?
    I have a web domain "www.myomain.com" but there is always index.php.mydomain appears after 'com'and becomes:
    www.mydomain.com/index.php/mydomain.

    How to keep only www.mydomain.com without index.php and other following annex ?

    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Miami, Florida
    Posts
    20,777
    Hello,
    This can be done with Apache mod_rewrite and a htaccess file
    Keith I Myers
    KMyers.me The rantings of a lunatic
    Join me on Technical.chat

  3. #3
    Quote Originally Posted by KMyers View Post
    Hello,
    This can be done with Apache mod_rewrite and a htaccess file
    Thanks, but how?
    Do you have you any simple, step by step approach to do it?

    Regards,

  4. #4
    Join Date
    Mar 2010
    Location
    Upstate New York
    Posts
    1,452
    John Rasri
    Private Label Live Chat Provider For Resellers
    GotLiveChat.com
    White Label/Brand-able live chat software solutions

  5. #5
    Join Date
    Jun 2001
    Location
    Kalamazoo
    Posts
    33,412
    Or, more specifically, something like
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
    Copied from a .htaccess file I use on a site. It works. So I'm pretty sure it's right.
    There is no best host. There is only the host that's best for you.

  6. #6
    Join Date
    Mar 2009
    Location
    Miami, Florida
    Posts
    20,777
    Quote Originally Posted by SoftWareRevue View Post
    Or, more specifically, something like
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
    Copied from a .htaccess file I use on a site. It works. So I'm pretty sure it's right.
    That looks correct, of course replace "example.com". The catch is the OP needs to ensure that their server supports mod_rewrite and if not, Apache may need to be re-bulit
    Keith I Myers
    KMyers.me The rantings of a lunatic
    Join me on Technical.chat

  7. #7
    Join Date
    Nov 2011
    Location
    Nasik, MH,INDIA
    Posts
    862
    Please use the following rewrite rules for more help.


    # Turn on rewrites.
    RewriteEngine on
    # Only apply to URLs on this domain
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$

    # Only apply to URLs that aren't already under folder.
    RewriteCond %{REQUEST_URI} !^/directory/

    # Rewrite all those to insert /folder.
    RewriteRule ^(.*)$ /directory/$1

  8. #8
    Join Date
    Dec 2011
    Posts
    91
    RewriteEngine On

    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Rewrite all other URLs to index.php/URL
    RewriteRule .* index.php/$0 [PT,L]


    -------------------------
    place this inside a file named .htaccess in your web docroot. This only applies to Apache. Nginx has a different rewrite syntax

    /etc/httpd/conf/httpd.conf must have the following line uncommented
    LoadModule rewrite_module modules/mod_rewrite.so
    Last edited by machinez; 03-06-2012 at 01:20 PM.
    BigInstance.com
    [+] VPS - KVM HVM - 4GB & up
    [+] Dedicated CPU core(s)
    sales [@] biginstance.com

  9. #9
    Thank you guys. I tried all the codes you pastes here but I still have the 'index.php'!
    I maybe processed it wrongly but, here is how I did:
    - enabled re-write mode in Apache,
    - open a new text file,
    - copied/paste the text you posted here,
    - save the file as .htaccess in the www root folder
    - close
    - refresh et check the url, I still see www.mydomainn.com/index.php/mydomain !

    Any idea to fix this?

    Thank you
    Last edited by Hostalker; 03-06-2012 at 03:50 PM.

  10. #10
    Join Date
    Mar 2009
    Location
    Miami, Florida
    Posts
    20,777
    Quote Originally Posted by Hostalker View Post
    Thank you guys. I tried all the codes you pastes here but I still have the 'index.php'!
    I maybe processed it wrongly but, here is how I did:
    - enabled re-write mode in Apache,
    - open a new text file,
    - copied/paste the text you posted here,
    - save the file as .htaccess in the www root folder
    - close
    - refresh et check the url, I still see index.php/mydomain !

    Any idea to fix this?

    Thank you
    Hello,
    You must make sure you web server is compiled with mod_rewrite support. I unfortunately cannot walk you through this process but there are tons of guides online
    Keith I Myers
    KMyers.me The rantings of a lunatic
    Join me on Technical.chat

  11. #11
    Join Date
    Dec 2011
    Posts
    91
    Quote Originally Posted by Hostalker View Post
    Thank you guys. I tried all the codes you pastes here but I still have the 'index.php'!
    I maybe processed it wrongly but, here is how I did:
    - enabled re-write mode in Apache,
    - open a new text file,
    - copied/paste the text you posted here,
    - save the file as .htaccess in the www root folder
    - close
    - refresh et check the url, I still see www.mydomainn.com/index.php/mydomain !

    Any idea to fix this?

    Thank you
    make sure in your conf file you enable overrides, you'll need them for .htaccess

    in /etc/httpd/conf.d/yourconffile.conf. You may have to replace directory with your own if the docroot is different.
    if you edit your conf file it requires a reload of Apache. "sudo /sbin/service httpd reload"

    <directory /var/www/html/>
    AllowOverride all
    </directory>
    BigInstance.com
    [+] VPS - KVM HVM - 4GB & up
    [+] Dedicated CPU core(s)
    sales [@] biginstance.com

  12. #12
    Join Date
    Jun 2011
    Location
    Karlstad, Sweden
    Posts
    354

    *

    Quote Originally Posted by SoftWareRevue View Post
    Or, more specifically, something like
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
    Copied from a .htaccess file I use on a site. It works. So I'm pretty sure it's right.
    ya its works in linux server wheather it works in Windows server
    Monitor Scout - Website & Server Monitoring
    50 different checks, SNMP monitoring and much more.
    https://www.monitorscout.com

  13. #13
    I am using windows, it didn't work!

Similar Threads

  1. How can I change the "index of" directory listing page?
    By chasebug in forum Hosting Security and Technology
    Replies: 5
    Last Post: 08-01-2010, 09:24 AM
  2. "index page"
    By chamelion in forum Hosting Security and Technology
    Replies: 1
    Last Post: 12-19-2006, 01:42 AM
  3. My site shows the "index of/" page
    By Alethea in forum Web Design and Content
    Replies: 22
    Last Post: 05-19-2005, 03:41 AM
  4. How to get rid of the "index of/" page?
    By Alethea in forum Web Design and Content
    Replies: 5
    Last Post: 05-05-2005, 11:07 AM
  5. Replies: 9
    Last Post: 10-26-2001, 07:51 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
  •