markveidemanis Posted November 27, 2013 Share Posted November 27, 2013 I have started to write a website from scratch and would like to know how to use mod_rewrite in order to shorten urls. I want to shorten http://f.marktest.co.uk/index.php?page=about to: http://f.marktest.co.uk/about I have tried several methods but was unable to find anything that worked. Quote Link to comment https://forums.phpfreaks.com/topic/284336-wwwcomindexphppageabout-to-wwwcomabout/ Share on other sites More sharing options...
Ch0cu3r Posted November 27, 2013 Share Posted November 27, 2013 (edited) You will need to recode your links to the new url format, eg <a href="http://site.com/about">About Us</a> Then you can apply the following in an .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?page=$1 Edited November 27, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/284336-wwwcomindexphppageabout-to-wwwcomabout/#findComment-1460385 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.