lukep11a Posted February 25, 2012 Share Posted February 25, 2012 I have checked phpinfo and there are no Loaded Modules and no mod_rewrite so mod_rewrite is not installed. I have no access to the httpd.conf file and I have contacted my host and they keep telling me that they can't make changes to the httpd.conf file and that I can enable it through the .htaccess file using RewriteEngine but nothing seems to be working. Does anyone know how I can fix this? Or am I just going to have to change my hosting company?? Any help would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/ Share on other sites More sharing options...
blacknight Posted February 26, 2012 Share Posted February 26, 2012 RewriteEngine On should turn it on for your site to test create a html file on your site called bob.html add RewriteRule ^bob\.html$ john.html after turning the engion on then go to yoursite.com/bob.html the address should change to yoursuite.com/john.html Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321334 Share on other sites More sharing options...
lukep11a Posted February 26, 2012 Author Share Posted February 26, 2012 Thanks for the reply, I have tried what you suggested and I am directed to an error page when I go to bob.html Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321394 Share on other sites More sharing options...
AyKay47 Posted February 26, 2012 Share Posted February 26, 2012 Thanks for the reply, I have tried what you suggested and I am directed to an error page when I go to bob.html Do both files exist in your server? The example was pseudo code. Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321434 Share on other sites More sharing options...
lukep11a Posted February 26, 2012 Author Share Posted February 26, 2012 Sorry, must of misunderstood the first reply, I have now created both files instead of just bob.html and it works, so how come I can't get my URL's to display correctly. I want the url www.mysite.com/football-team.php?team_id=1 for example to be displayed as www.mysite.com/football-team/1 This is the code of my .htaccess file: RewriteEngine On RewriteBase / RewriteRule ^football-team/([0-9]+)$ football-team.php?team_id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321449 Share on other sites More sharing options...
AyKay47 Posted February 26, 2012 Share Posted February 26, 2012 Sorry, must of misunderstood the first reply, I have now created both files instead of just bob.html and it works, so how come I can't get my URL's to display correctly. I want the url www.mysite.com/football-team.php?team_id=1 for example to be displayed as www.mysite.com/football-team/1 This is the code of my .htaccess file: RewriteEngine On RewriteBase / RewriteRule ^football-team/([0-9]+)$ football-team.php?team_id=$1 Really, this should work. What exactly do you mean by, "I can't get my URL's to display correctly"? Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321452 Share on other sites More sharing options...
lukep11a Posted February 26, 2012 Author Share Posted February 26, 2012 They still display as www.mysite.com/football-team.php?team_id=1 in the address bar and if I type it in the address bar as www.mysite.com/football-team/1 I get the error message 'Authorized Personnel only!' - which is the message I specify in my code to display when there is no team_id in the GET variable. Am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321455 Share on other sites More sharing options...
AyKay47 Posted February 26, 2012 Share Posted February 26, 2012 escape the dash in the pattern so it is not treated as a metacharacter. RewriteEngine On RewriteBase / RewriteRule ^football\-team/([0-9]+)$ football-team.php?team_id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321461 Share on other sites More sharing options...
lukep11a Posted February 26, 2012 Author Share Posted February 26, 2012 Tried your suggestion and it does exactly the same thing. I think you are right about the dash being the problem though because I chaged the RewriteRule to: RewriteRule ^team/([0-9]+)$ football-team.php?team_id=$1 and now when I type www.mysite.com/football-team/1 in the address bar it takes me to the correct page. It does not have any styling though that is applied in the template and in the css sheets. And, if I browse to the page it still shows in the address bar as www.mysite.com/football-team.php?team_id=1 Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321475 Share on other sites More sharing options...
AyKay47 Posted February 27, 2012 Share Posted February 27, 2012 . And, if I browse to the page it still shows in the address bar as www.mysite.com/football-team.php?team_id=1 well, because you will need to set up the internal links and such to point to the new rewritten url. You aren't actually changing the pages location, just pointing certain URL's to it. Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321555 Share on other sites More sharing options...
lukep11a Posted February 27, 2012 Author Share Posted February 27, 2012 Sorry but I'm obviously not getting this as I should, do I need to create a folder called 'team' in my root directory and then create a page for each team in there? Wouldn't that just defeat the object because I could've done that at first, rather than a dynamic link?? Quote Link to comment https://forums.phpfreaks.com/topic/257769-enabling-mod_rewrite/#findComment-1321650 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.