kalster Posted November 27, 2014 Share Posted November 27, 2014 I need help to shorten the following url in apache .htaccess example.com/index.php?q=1&w=2 if possible, the url that i would like is... example.com/index.php/1/2 or better yet... example.com/index/1/2 Quote Link to comment https://forums.phpfreaks.com/topic/292761-shorten-url-in-htaccess/ Share on other sites More sharing options...
Ch0cu3r Posted November 28, 2014 Share Posted November 28, 2014 (edited) Yes both types of urls are possible. Try adding the following to your .htaccess RewriteEngine On RewriteRule index(\.php)?/(\d+)/(\d+)/? index.php?q=$2&w=$3 But you will need to edit your links in your php script to use the new url format. mod_rewrite does not alter the the links for you. Edited November 28, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/292761-shorten-url-in-htaccess/#findComment-1497926 Share on other sites More sharing options...
kpmedia Posted December 18, 2014 Share Posted December 18, 2014 This page is really helpful: http://corz.org/server/tricks/htaccess2.php?page=all I came across it some time back when I needed help with a specfic htaccess syntax. Quote Link to comment https://forums.phpfreaks.com/topic/292761-shorten-url-in-htaccess/#findComment-1499949 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.