Solved

Using mod_rewrite

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

706 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

20 Experts available now in Live!

Get 1:1 Help Now