Solved

Using mod_rewrite

Posted on 2008-10-02
2
578 Views
Last Modified: 2013-11-10
I need help setting up mod_rewrite rules

I have the following file structure:

http://www.domain.com/index.php
http://www.domain.com/schools.php
http://www.domain.com/business.php
http://www.domain.com/contact.php

i would like it to appear as:

http://www.domain.com/
http://www.domain.com/schools/
http://www.domain.com/business/
http://www.domain.com/contact/

so thats it's all nice and clean, but i am having trouble figuring out the re_write rules :(
0
Comment
Question by:carlsilver
2 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 22622468
Did you already modify your html source code so that you've a link like 'a href="/schools/"''? Because mod_rewrite cannot modify the html source code but only rewrite or redirect incoming requests.

You have two options in order to direct requests like /schools/ to its corresponding php file:
Option one w/o mod_rewrite
 
DirectoryIndex index.php
Options +MultiViews
 
Option two:
DirectoryIndex index.php
RewriteEngine on
# if you don't call existing folders like /existent/, remove the condition
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ /$1.php [L]

Open in new window

0
 

Author Closing Comment

by:carlsilver
ID: 31502300
I couldnt get the mod_rewrite working, but Options +MultiViews works perfect! Many thanks! :D
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

838 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