1
votes

I have written HTML page and want to set RewriteRule. I have created .htaccess file into the folder written these:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ test.html [QSA,L]

It just redirects to http://example.com/test.html . I want to redirection to http://localhost/project/test

I think it is caused by httpd.conf or hosts file. But I can't find a way.

Edit: .htaccess file is under C:\xampp\htdocs\project

Thank you.

2
An internal redirection does not rewrite to URLs, but only to paths. Question is what you actually want. Rewriting to /project/test does not really make sense... - arkascha
Ok, I want to paths - sundowatch
That does not help. From what incoming URL to what internal path? - arkascha

2 Answers

0
votes

You may use this rule with appropriate RewriteBase value:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /project/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ test.html [L]
0
votes

I dont understand why do you want to use .htaccess file for redirect. Also note You can not move your site to localhost. You may directly do from your file

String site="/abc.com/test.html"
Response.setStatus(response.SC_MOVED_TEMPORARILY)
Response.setHeader("Location", site);