Solved

Using mod_rewrite

Posted on 2008-10-02
2
575 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
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, …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
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…

914 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

18 Experts available now in Live!

Get 1:1 Help Now