laanes Posted April 28, 2011 Share Posted April 28, 2011 Hi, I started reading a tutorial on using .htaccess but got stuck at the very beginning. Nothing seems to work, no matter what i write into the file. I have placed it into my WAMP servers root folder and copied examples from the tutorial to test. I can see that it is enabled in the apache modules list and it is loaded via the httpd conf file. How could i get this thing to work? Quote Link to comment Share on other sites More sharing options...
Maq Posted April 28, 2011 Share Posted April 28, 2011 What's happening? Can you give us an example of what you're trying to do? Quote Link to comment Share on other sites More sharing options...
requinix Posted April 28, 2011 Share Posted April 28, 2011 If you put absolute nonsense in the .htaccess and try to visit a page, do you get a 500 Internal Server Error? Quote Link to comment Share on other sites More sharing options...
laanes Posted April 28, 2011 Author Share Posted April 28, 2011 There is nothing specific that i am trying to do with it yet, just dropping in examples i can find on the web, like changing the default index page to something.html etc. If i put absolute nonsens into the .htaccess, i get: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@127.0.0.1 and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 28, 2011 Share Posted April 28, 2011 Apache is reading your .htaccess file so there isn't any issue with the configuration. What are trying to test which is not working for you? Quote Link to comment Share on other sites More sharing options...
laanes Posted April 28, 2011 Author Share Posted April 28, 2011 I would like to redirect everything in my root folder to home.php instead of index.php My htaccess file is located in the root folder and contains the following line: RewriteEngine on RewriteRule .* home.php Quote Link to comment Share on other sites More sharing options...
laanes Posted April 30, 2011 Author Share Posted April 30, 2011 I am using this rule: RewriteEngine on RewriteRule cat/(\w+)$ cat=$1 Result: Both of these URLs work: http://localhost/urls/cat/mickey http://localhost/urls/urls.php?cat=mouse I thought the URL will be rewritten when there is a pattern match, in the current case - cat/mickey should be rewritten to cat=mickey ? In fact, even http://localhost/urls/urls.php/cat/and/mouse/are/having/a/fight/over/bacon does not give an error, instead, it is still displaying the content of http://localhost/urls/urls.php What am i missing? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 30, 2011 Share Posted April 30, 2011 Your rewrite rule is incorret, it should be RewriteRule cat/(\w+)$ urls.php?cat=$1 Mod rewrite will not rewrite your existing links within your files. You'll need to change say <a hef="urls.php?cat=whatever">whatever</a> to <a hef="/cat/whatever">whatever</a> Yourself. If you went to http://localhost/urls/urls.php?cat=mouse it will not redirect the user to http://localhost/urls/cat/mouse In fact, even http://localhost/urls/urls.php/cat/and/mouse/are/having/a/fight/over/bacon does not give an error, instead, it is still displaying the content of http://localhost/urls/urls.php That is because that is infact a valid url 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.