bravo14 Posted February 18, 2010 Share Posted February 18, 2010 Hi Guys I am new to .htaccess and I am trying to shorten the URL from something like http://79.170.44.125/platinumbrides.co.uk/page.php?page_id=about_us to http://79.170.44.125/platinumbrides.co.uk/about_us Looking through tutorials out there I have the htaccess as RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?page_id=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ page.php?page_id=$1 However this is not working it still shows the original url and if I type inthe shortened URL I get an error saying the page cannot be displayed What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/192484-shortening-urls/ Share on other sites More sharing options...
PravinS Posted February 18, 2010 Share Posted February 18, 2010 Try like this Options +FollowSymLinks RewriteEngine On RewriteRule ^index.html index.php [NC] Quote Link to comment https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014209 Share on other sites More sharing options...
cags Posted February 18, 2010 Share Posted February 18, 2010 I always find that when debugging, adding the [R] flag to the end of rules can help you see why it isn't working. You don't appear to be specifying a RewriteBase, as such you should probably change your pattern to... RewriteRule ^([a-zA-Z0-9_-]+)/?$ /page.php?page_id=$1 The key difference is the forward slash before the second URI. Note I also combined the two RewriteRules by simply saying the trailing slash is optional. Quote Link to comment https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014253 Share on other sites More sharing options...
bravo14 Posted February 18, 2010 Author Share Posted February 18, 2010 Thanks for the replies I now have the .htaccess file set to RewriteRule ^([a-zA-Z0-9_-]+)/?$ /page.php?page_id=$1 When I go to a page I now get an error of You don't have permission to access /page.php on this server. The permissions are all ok. Quote Link to comment https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014271 Share on other sites More sharing options...
cags Posted February 18, 2010 Share Posted February 18, 2010 Looking at your original code it would appear that the IP is your domain meaning platinumbrides.co.uk is a folder on the domain. Which means you need to change the relative paths of your domains, in that case you're probably going to need something more like... RewriteRule ^platinumbrides\.co\.uk/([a-zA-Z0-9_-]+)/?$ /platinumbrides.co.uk/page.php?page_id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014277 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.