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

URL problem

I have this http://www.website.com/dir1/dir2/dir3/file.php

I need this file.php to be displayed as http://www.website.com/dir3/file.php

Is this impossible? I don't want users to see the whole path, so redirect is out.
0
rolandmy
Asked:
rolandmy
1 Solution
 
ukerandiCommented:
Encrypt the file path
0
 
Beverley PortlockCommented:
Look at URL rewriting with the MOD_REWRITE module in apache. Basically, you set up a rule that takes your existing URL and rewrites it behind the scenes. In your example it might look like this (UNTESTED)

RewriteEngine On
RewriteRule ^/([^/]+)/(.*)$   /dir1/dir2/$1/$2

0
 
Beverley PortlockCommented:
Actually, I should have had this

RewriteEngine On
RewriteRule ^/([^/]+)/(.*)$   /dir1/dir2/$1/$2 [L]

And here is a link to the official version  http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Beverley PortlockCommented:
I am obviously thinking one step at a time here.... do you need to reformat the link BEFORE displaying it or do you need the capability of handling a displayed link that does not physically match the folder structure? Mod-rewrite matches the second part of that question and may be needed anyway, but I am unclear from your question whether you have already done part 1 or still need to do it.

0
 
ukerandiCommented:
or you can use Frames
<HTML><HEAD>
<META NAME="description" CONTENT="WEBSITE.com">
<META NAME="keywords" CONTENT="">
</HEAD>
<FRAMESET border=0 rows="100%,*" frameborder="no" marginleft=0 margintop=0 marginright=0 marginbottom=0>
<frame src="http://www.WEBSITE.com" scrolling=auto frameborder="no" border=0 noresize>
<frame topmargin="0" marginwidth=0 scrolling=no marginheight=0 frameborder="no" border=0 noresize>
</FRAMESET>
</HTML>
0
 
Andrew DerseIT ManagerCommented:
Ok, stupid question here...why can't you just move the dir3 to your root level?

Instead of root/dir1/dir2/dir3/file.php...

Just put dir3 here:

root/dir3/file.php...

Like I said, stupid question, but I thought I would ask to obvious one first as no one else has yet...
0
 
Ray PaseurCommented:
@NUKIT: Exactly! the right idea!
0
 
re-searcherCommented:
use this one, it's work exactly for you...
Options +FollowSymlinks
RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_URI} /dir3/.*
RewriteRule dir3/(.*) /dir1/dir2/dir3/($1) [T=application/x-httpd-php,L]

Open in new window

0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

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