3

I have one HTML page. Assume the URL is

http://localhost/local/local.html 

but i want to mask the URL as

http://localhost/local/abc

can we do like this?

Tharif
  • 13,794
  • 9
  • 55
  • 77
Teja
  • 837
  • 3
  • 14
  • 24

3 Answers3

2

Create a .htaccess file in your root of your domain and add the following in that file:

RewriteEngine On
RewriteRule ^local.html$ http://localhost/local/abc/ [R=301,L]
Raman Sahasi
  • 30,180
  • 9
  • 58
  • 71
  • you don't have to create `abc.htaccess` just create simple `.htaccess` with no name. If an error occurs saying `Invalid File Name` then just create a new file and give name as `.htaccess.` (note that there's a period before and after "htaccess" – Raman Sahasi Aug 02 '16 at 12:03
  • I am using IIS, In wwwroot folder i have created ".htaccess" (*.*) and i have added above code as RewriteEngine On RewriteRule ^Ifa_Reportsmry.cshtml$ http://localhost/local/abc/ [R=301,L] and the url is :http://localhost/svymanalysis/Ifa_Reportsmry.cshtml. – Teja Aug 02 '16 at 12:11
  • the solution mentioned above works for apache web server. If you're using IIS, then refer to this stackoverflow question: http://stackoverflow.com/questions/25997830/how-can-i-enable-url-rewrite-module-in-iis-8-5-in-server-2012 – Raman Sahasi Aug 02 '16 at 12:18
  • I will check that...Thanks – Teja Aug 02 '16 at 12:27
0

In .htaccess add lines:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*) index.php?query=$1 [QSA,L]

When you visit https://localhost/local/abc in index.php parse $_GET["query"] how you want.

Dave
  • 2,764
  • 2
  • 15
  • 27
0

You can achieve the required action using a htaccess rule ,

Learn about htaccess at :

What is .htaccess file?

.htaccess rule you can implement is follows :

Options +FollowSymlinks
RewriteEngine on
rewriterule ^local/local.html (.*)$ http://localhost/local/abc$1 [r=301,nc]
Community
  • 1
  • 1
Tharif
  • 13,794
  • 9
  • 55
  • 77