?
Solved

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

Posted on 2005-03-02
3
Medium Priority
?
392 Views
Last Modified: 2013-12-16
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
Comment
Question by:Nexti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13438893
# use mod_rewrite in httpd.conf:
RewriteCond %{REQUEST_URI} ^/$
Rewrite Rule ^/$ /folder/folder/file.html [R,L]
0
 
LVL 3

Accepted Solution

by:
drcheap earned 500 total points
ID: 13645230
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13650109
we still need my suggestion to serv  'domain.com/' as requested in the question
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question