Solved

Apache mod_rewrite ?

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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JKS to store upstart data 2 85
apache vhosts on mac not being recognized 5 70
NGINX/Apache redirect on 403 and 404 5 72
Problem to go to Web page 2 99
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

896 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

12 Experts available now in Live!

Get 1:1 Help Now