1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

1.7 How Remove Index.php From Url With Htaccess

Discussion in 'General Troubleshooting' started by masih, Nov 29, 2016.

  1. masih

    masih New Member


    I need to remove "index.php" from URL and i want when a user try to open a url contained index.php , the site automatically redirect user to none index.php url .

    also i want to all links be without index.php contained!

    in google searches i found this htaccess code :
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
    but this code just redirect URLs with index.php to none index.php. (this can't change url and remove index.php in my site source)

    for example, this code work like this :
    my meen: i want a code to remove index.php in URLs for ever. no redirect after click!
    i hope that you understand my mean and question.
    i want make all of my pages URL without index.php contained in Source.

  2. valMETNG

    valMETNG Administrator Staff Member Admin

    I'm not sure this will get you 100% what you want but you should probably turn on Friendly URLs via Settings in the Admin dashboard (it's on the Main tab - the default is off). That will turn post URLs into the post title. There are other pages that will have index.php in the URL unless you do a large amount of customization. Why do you want to eliminate index.php in the URL?
  3. masih

    masih New Member

    Thanks for your reply. But your tips can't help me to resolve this problem .

    First i tried to enable Friendly URL option and use it , but when i enabled it, i got 500 Internal server error. after contacts with Host Provider, they say to me that i cant use this line in htaccess file :
    Options +Indexes +FollowSymlinks
    so i try to remove some lines in default htaccess file, then i resolve 500 error but when i clicking a post, it say:
    at finally i decided to use default URL and remove index.php from it.

    after my tests, i saw that when i remove index.php from every URLs, it can work good without any problems.

    so if you can give me a htaccess code to remove index.php from URLs for ever even in source and normal links.

    Thanks Again.
  4. valMETNG

    valMETNG Administrator Staff Member Admin

    Sadly, I'm not very good with htaccess so not sure I can help. But I'd suggest trying the friendly URLs with the standard htaccess file that comes with base Hotura as you shouldn't be getting 500 errors from it.
    masih likes this.
  5. masih

    masih New Member

    Can i remove "index.php" from URL with PHP codes in php files ?

    if i succeed to make my URL like following example which is better :D
    without "?" (question symbol)

    Why i want to remove index.php:
    I am currently designing a Android app for my website, and when i tried to open a post with "index.php" included in URL, the app can't open and get data from website!!

    this is wonderful that the app can't get data from a url that have index.php but when i try to open a url without index.php , the app works fine!
    for this reason i need to remove index.php from URL.

    i hop you help me.
  6. valMETNG

    valMETNG Administrator Staff Member Admin

    I've never gone through the code to evaluate how difficult to remove index.php but I expect it would take a great deal of customization. You'd likely have to hire someone. You'd probably find it easier to figure out why your Android app is having problems. If you do use htaccess to remove the question mark, you'd also want to get rid of the query string (e.g., "page=ID") and turn it into slashes (e.g., "site.ltd/page/id") which is doable.
    masih likes this.
  7. shibuya246

    shibuya246 Hotaru Developer Staff Member Admin

    if you want, try stackoverflow for articles on htaccess, but i agree with valMETNG, that you would be much better off with friendly urls. You need to ask your host what the 500 errror is pointing to in the error logs

    masih likes this.

Share This Page