codename25 Posted August 18, 2014 Share Posted August 18, 2014 Hi, How can i implement pretty urls for my website build in php by accessing .htaccess files?. something like....... RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^users/(\d+)*$ ./profile.php?id=$1 RewriteRule ^threads/(\d+)*$ ./thread.php?id=$1 RewriteRule ^search/(.*)$ ./search.php?query=$1 Quote Link to comment Share on other sites More sharing options...
Byron Posted August 18, 2014 Share Posted August 18, 2014 Is the code you posted not working for you? Check out this tutorial: http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049 Quote Link to comment Share on other sites More sharing options...
codename25 Posted August 20, 2014 Author Share Posted August 20, 2014 Hi, It is working with errors. When i go to users/myname the page profile.php?id=myname is coming but the images in the page are broken. When i checked the URL of the images it is showing like domain.com/users/image.jpg. But i saved my images in the home directory it is supposed to be like domain.com/image.jpg. But here it showing as image.jpg is in the directory of users. Please help me to solve this issue. Quote Link to comment Share on other sites More sharing options...
Byron Posted August 20, 2014 Share Posted August 20, 2014 Can you post a url to your page? Quote Link to comment Share on other sites More sharing options...
codename25 Posted August 21, 2014 Author Share Posted August 21, 2014 Hi, Here is the Url of one of my pages http://www.tuneitlouder.tk/viewnews/250580674 .Actual url id http://www.tuneitlouder.tk/viewnews.php?id=250580674 Quote Link to comment Share on other sites More sharing options...
hussam Posted August 21, 2014 Share Posted August 21, 2014 What CMS is that?how about changing the image links from images/myimage.png to /image/myimage.png so it's not a relative link to the current link but to top dir instead? Quote Link to comment Share on other sites More sharing options...
codename25 Posted August 22, 2014 Author Share Posted August 22, 2014 Hi, Its working now. Thanks Hussam. I should suppose to use /image/myimage.png. It was the problem. Thanks Byron for you support. Quote Link to comment Share on other sites More sharing options...
hussam Posted August 22, 2014 Share Posted August 22, 2014 In http://www.tuneitlouder.tk/viewnews/250580674, change the home link to / as well. Quote Link to comment Share on other sites More sharing options...
codename25 Posted August 28, 2014 Author Share Posted August 28, 2014 Thanks Hussam. I've changed it too. 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.