Search code examples
regexapache.htaccessmod-rewritedirectoryindex

Mod Rewrite code with out changing the url in address bar


I When I call http://www.mysite.in/abc/xyz it should show up http://www.mysite.in/abc/xyz/index.php but the url shout not change in address bar and it should work with out "/" in the address. Please any one help me with .htaccess code for apache 2.2

Note: It should not list the directory content, instead it should show the page. SEO Friendly URL.


Solution

  • 1. Without mod_rewrite solution:

    Just place this code on top of your .htaccess or in Apache config:

    DirectoryIndex index.html index.php
    

    2. mod_rewrite solution:

    Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^(abx/xyz)/?$ $1/index.php [L,NC]