• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

Apache: domain.com/folder/folder/file.html sould be domain.com

Hi All,

i have a file in 'domain.com/' on my webserver, that rediercts to 'domain.com/folder/folder/file.html', but users sould just see 'domain.com'.
As webserver i use Apache 2.

How sould i do this?

Thanks, Simon
0
Nexti
Asked:
Nexti
  • 2
1 Solution
 
ahoffmannCommented:
# use mod_rewrite in httpd.conf:
RewriteCond %{REQUEST_URI} ^/$
Rewrite Rule ^/$ /folder/folder/file.html [R,L]
0
 
drcheapCommented:
That would redirect only requests for "/" and would also change the URL in the browser to show the folders due to the redirect.  I think what Nexti wants is:

RewriteCond %{REQUEST_URI} ^/file.html$
Rewrite Rule ^/file.html$ /folder/folder/file.html [L]


Or, more generically:

RewriteCond %{REQUEST_URI} ^/[^/]+.html$
Rewrite Rule ^/([^/]+).html$ /folder/folder/$1.html [L]


The latter set will allow any file requested from root to be mapped to the corresponding file two levels deeper with the same name.  The URL the visitor sees will not be altered in any way, and non-html files or requests with path names will be unaffected  Examples:

http://domain.com/foo.html  =  /folder/folder/foo.html
http://domain.com/bar.html  =  /folder/folder/bar.html
http://domain.com/foo/bar.html = /foo/bar.html  (no change)
http://domain.com/foo.gif = /foo.gif  (no change)
http://domain.com/foo/bar.gif = /foo/bar.gif  (no change)



Disclaimer:  This is from my head & untested, but should work right.
0
 
ahoffmannCommented:
we still need my suggestion to serv  'domain.com/' as requested in the question
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
Tackle projects and never again get stuck behind a technical roadblock.
Join Now