Re: RewriteRules

From: Date: Mon, 12 Jan 2009 19:16:58 +0000
Subject: Re: RewriteRules
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-286121@lists.php.net to get a copy of this message
Jason Pruim wrote:
Hi Everyone, I know it's not a php question... But I know alot of you use rewrite rules and regular expressions and so I thought maybe you would be able to help me. The site: HTTP://purl.raoset.com/test112 test112 doesn't exist.. It's driven by the database using this rewrite rule: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /p.php [L] Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design completing the total look of the site :)
technically the same code as above should work even if you change you're links.. you see it's just redirecting everything not found to p.php so in p.php simply add in a print_r($_SERVER); exit(); at the top, upload to server then visit /test112/design in you're browser.. check the print_r output and you'll see the request in there, (variables sometimes differ, hence why I'm suggesting you check; you can skip this bit and jump right on to the next paragraph though) you can then simply: $request_page_parts = explode('/', $_SERVER['REQUEST_URI'); print_r($request_page_parts); then use whatever code you want to display the correct page based on the uri requested (as you want) I know this isn't the approach you expected but it basically hands off all page selection and processing to php, rather than a load of rewrite rules and lots of updating of .htaccess if you really want the rewrite rules then I'm sure you've had many other accurate replies with examples :)

« previous php.general (#286121) next »