1
votes

I have a question here:

On my server, there is:

http://www.domain.com/folder1/abc/html/index.html

In index.html there are some links of images or pdf files:

Then I use .htaccess make the URL shorter and it works:

http://www.domain.com/~abc

But from browser, the link of the image shows:

http://www.domain.com/pic.jpg

which can not be displayed. And even I tried to visit:

http://www.domain.com/~abc/pic.jpg

I got a 404 Error.

Here is my .htaccess, Am I wrong with something or missing something?

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^~(.*)$  /personalpages/personal_space/$1/html/
RewriteRule ^~(.*)$/(.*)$  /personalpages/personal_space/$1/html/$2

Any suggestions? Thanks in advanced.

1
But always starts with ~? It seems it is a relevant character in your rules.Felipe Alameda A
abc could be any name. Acturally, what I'm going to do is to build personal homepages: create a folder named abc(could be user's name), upload files he provied and make URL shorter for good remember.ryan.dingy
just like link I think this is a common usage.ryan.dingy

1 Answers

1
votes

You may try this instead:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI}  !/personalpages/ [NC]
RewriteRule ^([^/]+)/?$   /personalpages/personal_space/$1/html/  [L,NC]

RewriteCond %{REQUEST_URI}  !/personalpages/ [NC]
RewriteRule ^([^/]+)/(.*)/?$  /personalpages/personal_space/$1/html/$2  [L,NC]