LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache2 redirect (https://www.linuxquestions.org/questions/linux-server-73/apache2-redirect-683773/)

plk 11-16-2008 09:48 AM

Apache2 redirect
 
Hi there.

From what I understand from this page , aliasing is pretty straight forward.

However, what I want to do is:

When I'm developing on my localhost, I would like all my links pointing to sub pages to be something like href=www.mysite.com/mypage.php instead of just href=mypage.php or href=localhost.php

So what I though was add an alias like:

Code:

Alias www.mysite.com localhost
In the same sens that this shouuld work if I add to the apache2.conf file:

Code:

Alias site1 site2
After i restart apache, my browser still opens site1 instead of site2 .. is there something I don't get?

thanks in advance.

plk

anomie 11-16-2008 10:20 AM

Are you using 1.3 or 2.0 (or 2.2)? Your documentation URL points to 1.3, but your reference to apache2.conf suggest 2.0.

# httpd -v <-- will tell you

I'm not sure I understand what you are trying to do, but perhaps you are intending to look for the Redirect directive.

plk 11-16-2008 02:47 PM

Sorry Im on Apache 2.

Ok, so what im trying to do is:

Say I have a piece of code on my website like:

PHP Code:

<a href="http://www.mysite.com/images/picture.jpg">Click here</a

And im developing it on my local computer. What I want is to edit my files and check if everything works without having to develop on the server. Also, without having to edit the above line of code so it reads

PHP Code:

<a href="http://localhost/images/picture.jpg">Click here</a

I think Its clearer than before :-)

plk 11-16-2008 03:15 PM

ignore this post, mistake.

Still waiting for some help tho :-)

Shinigami101 11-16-2008 07:27 PM

Quote:

Originally Posted by plk (Post 3344009)
Sorry Im on Apache 2.

Ok, so what im trying to do is:

Say I have a piece of code on my website like:

PHP Code:

<a href="http://www.mysite.com/images/picture.jpg">Click here</a

And im developing it on my local computer. What I want is to edit my files and check if everything works without having to develop on the server. Also, without having to edit the above line of code so it reads

PHP Code:

<a href="http://localhost/images/picture.jpg">Click here</a

I think Its clearer than before :-)

You should never has to use;

PHP Code:

<a href="http://localhost/images/picture.jpg">Click here</a

when making a website you should just be able to

PHP Code:

<a href="images/picture.jpg">Click here</a


plk 11-17-2008 12:16 AM

Yeah I actually need to use that. I'm concerned about search engines ranking so you know ...

sleddog 11-17-2008 08:13 PM

You can use:

Code:

<a href="http://www.mysite.com/images/picture.jpg">Click here</a>
And make an entry in the hosts file on your local computer. The file is /etc/hosts on Linux and something like C:\windows\system32\drivers\etc\hosts on a Windows box.

Add a line like:

Code:

192.168.1.1 www.mysite.com
Substituting your local IP and the domain you're actually using. Restart your web browser so it sees the change.

Remove the line when you're ready to go live on the server.

plk 11-27-2008 01:37 PM

Thanks a lot man.

However, I decided to do something else.

I'll just include a $path variable to all my php files on the server so I can actually develop multiple servers at the same time.

If using the etc/hosts method (which works just fine) it redirects to my localhost IP, no sub folders etc..

Anyhow. Thank you!!

plk


All times are GMT -5. The time now is 04:22 AM.