CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   mod_rewrite : make a "fake" directory that displays an "index.php" from another folde (http://www.codingforums.com/showthread.php?t=286957)

DR.Wong 02-03-2013 01:11 PM

mod_rewrite : make a "fake" directory that displays an "index.php" from another folde
 
Hey there,

I'm attempting to use clean URLs.

The about page my site is located at http://www.example.com/frontEnd/about.php

I'd like to access it by merely typing in http://www.example.com/about/

Similar to how you clean ugly variables in a URL :

Code:

RewriteEngine On
RewriteRule ^([\w\-]+)/?$ index.php?var=$1

I've been playing around with mod_rewrite in the .htaccess file in the root directory, but I can't seem to get it to work.

I've tried :

Code:

RewriteEngine On
RewriteRule ^/about/?$ frontEnd/about.php

But this doesn't seem to work.

DR.Wong 02-03-2013 01:53 PM

Solved
 
I've figured it out.

The problem was that I included a "/" before the name of the "fake" directory.

Here's the solution :

Code:

RewriteEngine On
RewriteRule ^contact/?$ frontEnd/contact.php
RewriteRule ^about/?$ frontEnd/about.php

This is really useful if you want to keep your website directory structure well organized!


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.