Solved

Apache mod_rewrite ?

Posted on 2013-12-18
5
182 Views
Last Modified: 2014-01-12
Hello,

I have apache web server which is hosting some php sites. The sites are accessed locally (within the same network).

How can I setup apache server that url would always be the same?

Example.

My site is in directory /var/www/html/mysite/ and is accessed via: http://server.domain.local/mysite

when I click a link on this site the url changes to:
http://server.domain.local/mysite/links/about.php

how can I setup apache so that in this case the url would be
http://server.domain.local

or

http://server.domain.local/mysite

thx.
0
Comment
Question by:SimpleJ
  • 2
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Steve Bink
ID: 39728408
Try one of these:
# to make your default document go to about
RewriteRule ^/?$ /mysite/links/about.php [NC,L]

# to make /mysite go to about
RewriteRule ^/?mysite/?$ /mysite/links/about.php [NC,L]

Open in new window


I'd also like to add that if you'd like that page to be your default document, perhaps you should move it to the root of the site as the index.php page.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39728427
I hope you realize that if you have only the one URL, no one can bookmark any of the other pages?
0
 
LVL 1

Author Comment

by:SimpleJ
ID: 39728916
I realize all disadvantages of this approach. However I want always to show just domain or domain/folder1

Just like using frames (the url would always be http://server or http://server/folder1 no matter what the "underlying" url i.e. http://server/folder1/links/wo/content.php?id=2)

Is this possible?
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 250 total points
ID: 39729534
Sure it's possible - by using frames.  That's how they work.  Though you could probably set it up, rewrites are not designed to implement this kind of system, and the implementation would be a clumsy hack at best.  There are already processes in place to do what you want.  I recommend looking at them instead of forcing a square peg into the round hole.
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 39729801
In software like Wordpress, there is code-wise really only one page, the index.php page, which loads content as needed.  But even there, there are parameters passed in the URL to tell it what content is wanted.  You're trying to create a method that can read your mind.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now