dhope Posted May 2, 2011 Share Posted May 2, 2011 Hi, I currently have the following code in my .htaccess to remove the .php extension from my files. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php How would I change this so that "www.mydomain.com/services" becomes "www.mydomain.com/page/services" I'm not really that clued up on mod_rewrite, please can someone point me in the right direction. Thank you Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 2, 2011 Share Posted May 2, 2011 Not sure what you want to do here. Do you want www.mydomain.com/services to be redirected to www.mydomain.com/pages/services and then have www.mydomain.com/pages/services call www.mydomain.com/services.php? Or just have www.mydomain.com/services call www.mydomain.com/pages/services.php Quote Link to comment Share on other sites More sharing options...
dhope Posted May 2, 2011 Author Share Posted May 2, 2011 Hi, If possible I would like the user to see "www.mydomain.com/pages/services" and the server to call "www.mydomain.com/services.php". Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 2, 2011 Share Posted May 2, 2011 You'll want to add another rule. Add this line before your first rule. RewriteRule ^pages/(.*)$ $1.php [L] Quote Link to comment Share on other sites More sharing options...
dhope Posted May 2, 2011 Author Share Posted May 2, 2011 Thank you. Is there away to update the css/image links without changing them on the page? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 2, 2011 Share Posted May 2, 2011 Not really. You should start your links with a / that way your links will always load from the root of your site. Otherwise when you go to mydomain.com/pages/services your web browser will try to load your images/css files from mydomain.com/pages/services 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.