Jump to content

Enabling mod_rewrite


lukep11a

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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"?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

. 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.

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.