homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Url rewriting question

 10:05 am on Mar 16, 2003 (gmt 0)

Currently I use URL rewriting on my website, but for each main directory, I have an entry in the .htaccess file, and a file without extension:




<Files Red>
ForceType application/x-httpd-php

Now is it possible to reduce the structure to just one file, that can read Red, Green, ... as parameters?




 9:45 pm on Mar 16, 2003 (gmt 0)

Try Apache [httpd.apache.org] mod_rewrite [httpd.apache.org]

RewriteEngine On
RewriteRule ^(.*)$ /index.php?color=$1 [L]

That should do it.


 10:01 pm on Mar 16, 2003 (gmt 0)

I may have misunderstood. If the folders "red" and "green" actually exist, just have a page named index.php in each folder and the url will resolve.

If you want to have one dynamic processing page in your root folder that will handle the parameters, use the method from msg#2. you will have to change the url in the rewrite to your script.

RewriteEngine On
RewriteRule ^(.*)$ /dynamic_script.php?color=$1 [L]

Now you can call the variable $color to determine what to show on the page.


 10:21 pm on Mar 16, 2003 (gmt 0)

Thank you birdman for your reply! I think what you wrote will help me. Unfortunately I am not able to implement the code right now, but I will let you know if it works. Just to make sure you understood me correctly, I will tell you again what I need in a less complicated way. Basically I want any Url to be directed to one file.


should open the following file: mydomain.com/database.php

-- .htaccess --
RewriteEngine On
RewriteRule ^(.*)$ /database.php [L]


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved