homepage Welcome to WebmasterWorld Guest from 54.234.128.25
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Url rewriting question
globay




msg:1517433
 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:

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




msg:1517434
 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.

Birdman




msg:1517435
 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.

globay




msg:1517436
 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.

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!

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