mod_rewrite question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

mod_rewrite question

Post by GeXus »

Hello all,

I have the following rewrite rule setup

Code: Select all

 
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ product.php?product=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L] 
 
Basically, this allows me to do something like http://www.domain.com/productname/?some=1&another=2 and gives me productname as the product variable.

Now, I want to have it so I can maintain this /productname/ url but access other pages, so for example

http://www.domain.com/productname/register.php , where register.php lies on the root domain... Any ideas how I can do this?

Thank you!
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: mod_rewrite question

Post by josh »

You want the Mod_Alias module, not mod_rewrite
http://httpd.apache.org/docs/1.3/mod/mo ... aliasmatch
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: mod_rewrite question

Post by GeXus »

Hmm.. Looked into this, but not exactly sure... any other tips?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: mod_rewrite question

Post by josh »

Not sure what you mean. If you want some scripts to be used outside the web root, the alias directives do that for you. They use the same syntax as regular expressions if you look at my link.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: mod_rewrite question

Post by GeXus »

Well I still want it to be in the webroot, so the current modrewrite that I'm using works... but only for product.php that's declared within the htaccess, there are other pages that are in the web root, that I would like to be accessed via a different URL, so for example having /register.php be accessed via the wildcard/register.php
Post Reply