?
Solved

Using mod_rewrite

Posted on 2008-10-02
2
Medium Priority
?
590 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 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