Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
Url rewriting question globay
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 </Files> ...
Now is it possible to reduce the structure to just one file, that can read Red, Green, ... as parameters?
Try Apache [ httpd.apache.org] mod_rewrite [ httpd.apache.org]
RewriteRule ^(.*)$ /index.php?color=$1 [L]
That should do it.
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.
RewriteRule ^(.*)$ /dynamic_script.php?color=$1 [L]
Now you can call the variable $color to determine what to show on the page.
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] ---------------