Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-28-2011, 09:55 PM   PM User | #1
XmisterIS
Regular Coder

 
Join Date: Jun 2010
Posts: 239
Thanks: 50
Thanked 6 Times in 6 Posts
XmisterIS is an unknown quantity at this point
mod_rewrite advice please!

My website uses a CMS which loads page content according to the value of a GET var called "page".

E.g. http://www.mysite.com/index.php?page=mypage will load the content for mypage.

How can I generically mod_rewrite http://www.mysite.com/index.php?page=xxx as http://www.mysite.com/xxx ?
XmisterIS is offline   Reply With Quote
Old 06-28-2011, 10:25 PM   PM User | #2
eak
Regular Coder

 
eak's Avatar
 
Join Date: Jun 2002
Location: Nashville, TN
Posts: 354
Thanks: 0
Thanked 26 Times in 26 Posts
eak is on a distinguished road
Try something like this (untested):

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?page=$1 [L]
__________________
eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."
eak is offline   Reply With Quote
Old 06-30-2011, 07:08 AM   PM User | #3
XmisterIS
Regular Coder

 
Join Date: Jun 2010
Posts: 239
Thanks: 50
Thanked 6 Times in 6 Posts
XmisterIS is an unknown quantity at this point
Many thanks for that.

Reading through, I realise I have no idea how it works! Seems I need to familiarise myself with mod_rewrite. Can you recommend a good online tutorial that explains the syntax?
XmisterIS is offline   Reply With Quote
Old 07-08-2011, 10:37 PM   PM User | #4
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
I've always found...

http://net.tutsplus.com/tutorials/ot...te-for-apache/

... to be quite a good all round tutorial on mod_rewrite. Combine it with a bit of Regular Expression knowledge and you should be golden.
Cags is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:52 AM.


Advertisement
Log in to turn off these ads.