|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I'm trying to use mod_rewrite module for apache on windows 2k. On httpd.conf I removed the # sign at the begining of the line that loads the module, and I tried many rewrite rules that I collected from the net, but none of them worked.... I'm sure that rewrite module isn't working properly... What should I do to run it ? For instance the following lines didn't work : RewriteEngine on RewriteRule ^/articles/(.*) /articles?rest_of_url=/$1 or; RewriteRule ^story/(.*)$ stories.php?story=$1 Thanx |
|
#2
|
|||
|
|||
|
>> RewriteRule ^/articles/(.*) /articles?rest_of_url=/$1
>> or; RewriteRule ^story/(.*)$ stories.php?story=$1 When you are doing internal redirection, you should give absolute file system path to your script by putting / first. Your /articles tells Apache your articles resides in your root directory (ex. C:\articles) which obviously not where it is. In your 2nd rule, you didn't specify the file system path, so that assumes to be the current directory of your story directory. It's also a good practice to tell Apache what kind of handler stories.php is. That's to put [T=application/x-httpd-php]. Anyhow, do a search in this forum for your answer as your case has been discussed million times here. |
|
#3
|
|||
|
|||
|
Hi,
Thanks for your reply, I searched this forum and found many answers for my problems, but I couldn't make it work so I posted here. Actually I'm trying to run the following lines, but I tried the others to test the rewrite module... Here is some code that I copied from a post that you have sent before : # enabling mod_rewrite RewriteEngine on # for request of http://linux.localhost/ or http://linux.localhost or http://linux.localhost/index.php RewriteCond %{REQUEST_URI} ^/index\.php.* # do not continue and last it RewriteRule ^(.+) - [L] # if request is anything else RewriteCond %{REQUEST_URI} ^/(.*)$ # check and see if the pattern matches # http://linux.localhost/foo -> matches and $QUERY_STRING returns group=foo§ion=category= # http://linux.localhost/foo/bar -> matches and $QUERY_STRING returns group=foo§ion=bar&category= # http://linux.localhost/foo/bar/ha -> matches and $QUERY_STRING returns group=foo§ion=bar&category=ha RewriteRule ^([A-Za-z0-9]+)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)$ index.php?group=$1\§ion=$2\&category=$3 [T=application/x-httpd-php,L] Neighter this nor the others work on my sytem.... ![]() |
|
#4
|
|||
|
|||
|
erdincyilmazel:
What kind of errors are you getting? Have you restarted apache? Have you loaded the rewrite module? When you restart apache with your rewrite engine "on" do you get any errors? Let me know. I am running Apache/PHP/MySql on Win2k with no problem and I use many rewrite rules. Piet
__________________
![]() - Please help us build our Hewlett Packard community - Check us out, or tell someone who might find us useful Last edited by piet : April 7th, 2003 at 03:38 PM. |
|
#5
|
|||
|
|||
|
I sometimes ged bad request errors at the browsers, and the other errors are everytime 404 errors. I placed the code that I pasted below in my httpd.conf file or in a .htaccess file.. nothing changed.
When I try to access http://localhost/foo/foo2 or something like that, I get 404 errors... Apache runs without an error.. It loads the module I think... I restarted the apache service dozens of times... I didn't istall php as an apache module.. I'm using it in cgi mode.. If it will help I can post my httpd.conf file... Piet can you send me any code that works well on your system ? or can you contact me by emai icq etc. ? Thanks a lot... jam@pearljam.org |
|
#6
|
|||
|
|||
|
erdincyilmazel (what is that anyways?):
Let's keep posting here on the forum for the meantime so that others who come across this problem can fix it too. First off, you can start by reading this thread. Here you will see some code to put into your httpd.conf file. http://forums.devshed.com/showthrea...9986&forumid=15 Second. After looking at my httpd.conf file the only thing different that I have is the that I surrounded my Rewrite Rules in <Directory "/path/to/index.php folder (not the actual file)"></Directory> tags. Have you done this? Make sure your path is in quotes. In addition, make sure your DocumentRoot "/root/" is correct and that it matches the <Directory> path. So for example, if your DocumentRoot is "/apache/webroot" then your Directory should be <Directory "/apache/webroot">. The script that is parsing the URL, index.php, should sit in the "webroot" folder. Let me know if this helps. You are welcome to post your httpd.conf file but please remove the # comments. Piet Last edited by piet : April 7th, 2003 at 03:39 PM. |
|
#7
|
|||
|
|||
|
I finally solved my problems...
As you said I placed the code between <Directory "C:\Apache\htdocs"> </Directory> tags... then I received Bad Request Errors from the browser, but then I changed the line : RewriteRule ^([A-Za-z0-9]+)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)$ index.php?group=$1\§ion=$2\&category=$3 [T=application/x-httpd-php,L] and added a / infront of index.php so it worked... I finally understood the basics of mod_rewrite... Thank you all for your helps. ![]() |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > mod_rewrite on windows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|