Forum Moderators: phranque

Message Too Old, No Replies

apache moved site to subdirectory, update .htaccess & relative path

apache rewritebase alias rewriterule

         

juicytoo

12:40 pm on Dec 18, 2006 (gmt 0)

10+ Year Member



Hi,

Your help is appreciated.

I moved my website from the root directory to a subdirectory.

localwebj:85
to
localwebj:85/site

The relative links within the existing pages are not working because the ServerRoot/DocumentRoot has changed.

Without changing every single file and the internal links, is there a way to update the .htaccess file to make the website under the subdirectory work as before?

I know it's something to do with Alias and rewriterule, but I can not figure it out.

I am currently testing it on a local server.

Quote:
The document root is

Code:

<VirtualHost 127.0.0.1:85>
ServerAdmin service@examplej.com.au
DocumentRoot "D:/Program Files/www/localwebj"
ServerName localwebj
ErrorLog logs/localwebj.error.log
CustomLog logs/localwebj.access.log common
</VirtualHost>

Quote:
The structure is as follows:

Quote:

/.htaccess -
/index.html
/site
/site/.htaccess - [2]
/site/index.html

In the [1] .htaccess file I have

Code:

RewriteEngine On

Options +FollowSymLinks
Options +SymlinksIfOwnerMatch

RewriteBase /
RewriteCond %{HTTP_HOST} ^examplej(:85)+
RewriteCond %{REQUEST_URI}!site/
RewriteRule ^(.*)$ site/$1 [L]

That's fine and typing in

examplej:85

redirects me to

examplej:85/site

Quote:
The Question now is.

Is it possible to update the .htaccess file so I do not have to update all the internal links within the html files.

Currently the website at examplej:85/site is not working because the internal links are referring to the document root at

"D:/Program Files/www/example-support-j"

but it needs to look at
"D:/Program Files/www/example-support-j/site"

is there are way to update this in the .htaccess file, so I do not have to get to every internal link and update the link.

Much appreciated.

Ed

[1][edited by: jdMorgan at 10:52 pm (utc) on Dec. 18, 2006]
[edit reason] Examplified [/edit]