Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Virtual Directory

I use Apache 1.3

I'd like to have a virtual directory so that when the user accesses
http://localhost/somedirectory/ he in fact accesses http://localhost/ but thinks he's in http://localhost/somedirectory/

Thanks,
Nima
0
SWB-Consulting
Asked:
SWB-Consulting
  • 2
  • 2
1 Solution
 
SWB-ConsultingAuthor Commented:
one more thing: i want it to be done in the htaccess file not in the httpd.conf
0
 
ahoffmannCommented:
use mod_rewrite:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^/somedirectory(.*)$ /$1 [R,L]
0
 
SWB-ConsultingAuthor Commented:
I tried it in the .htaccess but it didn't work. It didn't find the address http://localhost/domedirectory/
0
 
ahoffmannCommented:
which .htaccess, that in domedirectory?
you better write these rules in httpd.conf
0
 
caterham_wwwCommented:
for so called per-dir context (.htaccess; <Directory> and <Location> containers in httpd.conf), the pattern of a rewriteRule does not start with a leading slash. If you need an external redirect (-> url changes in the locationbar), add the R-Flag ([R=301,L]). Make sure you're sending a statuscode 301 moved permanently, otherwise search engines will not follow this redirection.

####http://localhost/.htaccess##
RewriteEngine On
RewriteRule ^somedirectory/?(.*)$ /$1 [L]
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now