Solved

Apache mod_rewrite ?

Posted on 2013-12-18
5
189 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 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.

713 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