Welcome to WebmasterWorld Guest from 54.159.26.69

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Url rewriting question

     

globay

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

10+ Year Member



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:

Addesses:

mydomain.com/Red
mydomain.com/Green
...

.htacces:


<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?

Thanks
--
globay

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



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

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

That should do it.

Birdman

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

WebmasterWorld Senior Member 10+ Year Member



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.

globay

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

10+ Year Member



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.

mydomain.com/Any/complicated/Url.goes?here

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

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

Thanks
--
globay!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month