Solved

Apache mod_rewrite ?

Posted on 2013-12-18
5
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 83

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 83

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

732 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