Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Redirect index.php request to http://localhost/website/ using .htaccess

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #43749
    ajnoguerra
    Participant

    I’m not so familiar with configuring my .htaccess yet so please help me out.

    I have a link that goes to the index.php but I don’t want index.php to appear in my url

    eg.
    http://localhost/website/index.php

    I want it to be redirected to the root folder which is

    http://localhost/website/

    So i tried searching for answers and this is what I got so far.

    RewriteEngine on

    Options +FollowSymLinks
    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ http://localhost/website/$1 [R=301,L]

    Now when I try to click home in my local website, instead of redirecting me to

    http://localhost/website

    my url bar displays this –

    http://localhost/Applications/XAMPP/xamppfiles/htdocs/website/localhost/website/

    Can anyone explain what’s going on?

    #130494
    __
    Participant

    > I have a link that goes to the index.php but I don’t want index.php to appear in my url

    THIS is the part you don’t understand. If you don’t want the link to show `…index.php` in the address bar, then change the link, not your server. In and of itself, this has absolutely nothing to do with mod_rewrite.

    Take this

    my link

    …and replace it with this

    my link

    In most cases, you won’t need to do anything more – when given a path to a directory, Apache is typically already configured to look for a file named `index.php` (among others) and serve it if found.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Other’ is closed to new topics and replies.