简体   繁体   中英

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.

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]

This is how I fixed it

Added the bellow code to root folder .htaccess

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

And added the bellow code to the .htaccess file in side the xyz.html folder

DirectorySlash Off
Directoryindex index.php
Options -indexes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM