Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. .htaccess removing index.php from URLs

.htaccess removing index.php from URLs

Scheduled Pinned Locked Moved Web Development
helpphpapachedatabasecom
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL http://mydomain.com/index.php should be changed to http://mydomain.com/ and http://mydomain.com/folder/index.php should be http://mydomain.com/folder/. However, I also want to preserve any parameters passed to the page, e.g. http://mydomain.com/index.php?id=22&c=1 should be changed to http://mydomain.com/?id=22&c=1 and http://mydomain.com/folder/index.php?id=22&c=1 should be http://mydomain.com/folder/?id=22&c=1. I've tried RewriteRule ^(.*)$ /index.php?/$1 [NC] but that just gives me an HTTP 500. Also tried RewriteRule ^index.php - [NC] but that apparently does nothing. Help? :(( Thanks.

    S G 2 Replies Last reply
    0
    • H hxhl95

      Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL http://mydomain.com/index.php should be changed to http://mydomain.com/ and http://mydomain.com/folder/index.php should be http://mydomain.com/folder/. However, I also want to preserve any parameters passed to the page, e.g. http://mydomain.com/index.php?id=22&c=1 should be changed to http://mydomain.com/?id=22&c=1 and http://mydomain.com/folder/index.php?id=22&c=1 should be http://mydomain.com/folder/?id=22&c=1. I've tried RewriteRule ^(.*)$ /index.php?/$1 [NC] but that just gives me an HTTP 500. Also tried RewriteRule ^index.php - [NC] but that apparently does nothing. Help? :(( Thanks.

      S Offline
      S Offline
      shamly
      wrote on last edited by
      #2

      would adding the following line in .htaccess solve your issue? DirectoryIndex index.php or do you want the page to redirect to http://mydomain.com/ even when a user enters http://mydomain.com/index.php ?

      Tech Notes on Web Development and Software Development Technology

      H 1 Reply Last reply
      0
      • S shamly

        would adding the following line in .htaccess solve your issue? DirectoryIndex index.php or do you want the page to redirect to http://mydomain.com/ even when a user enters http://mydomain.com/index.php ?

        Tech Notes on Web Development and Software Development Technology

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        Yeah, that. I've tried DirectoryIndex already.

        1 Reply Last reply
        0
        • H hxhl95

          Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL http://mydomain.com/index.php should be changed to http://mydomain.com/ and http://mydomain.com/folder/index.php should be http://mydomain.com/folder/. However, I also want to preserve any parameters passed to the page, e.g. http://mydomain.com/index.php?id=22&c=1 should be changed to http://mydomain.com/?id=22&c=1 and http://mydomain.com/folder/index.php?id=22&c=1 should be http://mydomain.com/folder/?id=22&c=1. I've tried RewriteRule ^(.*)$ /index.php?/$1 [NC] but that just gives me an HTTP 500. Also tried RewriteRule ^index.php - [NC] but that apparently does nothing. Help? :(( Thanks.

          G Offline
          G Offline
          Gerben Jongerius
          wrote on last edited by
          #4

          You might wanna try something in the lines of RewriteRule ^([^/?]+/)*index.php(\?.*)?$ $1 [NC,QSA,L]. This will rewrite all the index.php to folder/?whatever. You will probably need to play with it a little as I didn't have time to thouroughly check it. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups