PTS Posted June 2, 2011 Share Posted June 2, 2011 Was hoping someone might be able to help me with a rewrite issue I'm having. I would like for my clients to control the URL of any page they create in our custom CMS. Let's say my client creates three pages in our CMS and enters the following values for the FURL field: 1. "services/design.php" 2. "products/software/1/" 3. "news" I would like for the following URLs to work based on those FURL field entries: 1. http://www.domain.com/services/design.php 2. http://www.domain.com/products/software/1/ 3. http://www.domain.com/news Basically, I'd like for them to control whatever the URL is after "http://www.domain.com/". Is this possible? I've tried various methods and all have failed. The dynamic link is: http://www.domain.com/content.php?furl=page-link-here Hope someone might be able to help me out. Thanks! Quote Link to comment Share on other sites More sharing options...
requinix Posted June 2, 2011 Share Posted June 2, 2011 1. Store everything in a database (duh). 2. Use mod_rewrite to redirect any non-existant URLs to some PHP script (your content.php I would guess). RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?(.*) content.php?furl=$1 [L] 3. Have the script display the content associated with the URL, or show an error if there isn't anything. Quote Link to comment Share on other sites More sharing options...
PTS Posted June 2, 2011 Author Share Posted June 2, 2011 THANK YOU! You are a life saver. I was messing around with the RewriteRule seven ways to Sunday. I never knew you needed these two lines for it to work: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d I tested out a variety of inputs and all the ones that failed before are working correctly now. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 2, 2011 Share Posted June 2, 2011 I never knew you needed these two lines for it to work: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Without them, mod_rewrite will apply (successfully, because the regex is so broad) that Rule to every request that comes in. Everything will go to content.php: requests to existing PHP scripts, CSS and JavaScript files, images... With them, only requests that don't exist (legitimate 404s or otherwise) will make it to the Rule. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.