htaccess to windows

Topics: Developer Forum, Project Management Forum, User Forum
Nov 27, 2008 at 2:53 AM
Hello
I have a problem with my new windows server. I was using .htaccess on my linux server and now i have carried my websites to a windows host. I have tried to use .htaccess but not able to use it. I have installed IonicIsapiRewriter-1.2.15 as a Isapi filter to my IIS. I have tried to configure the IsapiRewrite4.ini   But my host still doesn't redirects. I am sure that i have made mistakes at changing the .htaccess to .ini file. I will be glad if someone can help me to change the .htaccess file. I am pasting it below.
Thank you very much



Options -MultiViews
RewriteEngine On


RewriteRule ^video/(.*)/(.*).html detail.php?vid=$1
RewriteRule ^profile/([a-zA-Z0-9]*)$ user_profile.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/$ user_profile.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/videos$ user_videos.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/videos/$ user_videos.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/videos/page([0-9]*).html user_videos.php?u=$1&p=$2
RewriteRule ^profile/([a-zA-Z0-9]*)/favorites$ user_favorites.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/favorites/$ user_favorites.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/favorites/page([0-9]*).html user_favorites.php?u=$1&p=$2
RewriteRule ^profile/([a-zA-Z0-9]*)/playlists$ user_playlists.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/playlists/$ user_playlists.php?u=$1
RewriteRule ^profile/([a-zA-Z0-9]*)/playlists/page([0-9]*).html user_playlists.php?u=$1&p=$2

RewriteRule ^profile/([a-zA-Z0-9]*)/playlists/([a-zA-Z0-9]*)/(.*)/page([0-9]*).html user_playlists_entry.php?u=$1&lid=$2&p=$4
RewriteRule ^profile/([a-zA-Z0-9]*)/playlists/([a-zA-Z0-9]*)/(.*)/$ user_playlists_entry.php?u=$1&lid=$2
#RewriteRule ^profile/([a-zA-Z0-9]*)/playlists/([a-zA-Z0-9]*)/(.*)$ user_playlists_entry.php?u=$1&lid=$2

#other page, process in list.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.* list.php



Nov 30, 2008 at 4:54 PM
Hello
I am trying to make the htaccess to change .ini file. I have tried to rewrite the url with the given code but it doesn't works.
Here is my .ini file
RewriteLog  c:\temp\iirfLog.out
RewriteLogLevel 1
MaxMatchCount 10
RewriteRule ^/video/(.*)/(.*).html /detail.php?vid=$1


and when i request the



http://mydomain.com/video/9zZLpZKQyJA/Arka.html
It gives me 404 Not Found error.


I think the isapi file is working cause when i look to logs it seems that it's working.
Anyone can give me an idea to solve this issue?

Here is the log for .ini file.



Sun Nov 30 18:48:15 -  3488 - ReadConfig: setting LogLevel to 1
Sun Nov 30 18:48:15 -  3488 - ReadConfig: line 31: MaxMatchCount 10
Sun Nov 30 18:48:15 -  3488 - ReadConfig: line  40: RewriteRule (rule 1)  '^/video/(.*)/(.*).html'  '/detail.php?vid=$1'   (null)
Sun Nov 30 18:48:15 -  3488 - ReadConfig: Done reading, found 1 rules (0 errors, 0 warnings) on 42 lines



Coordinator
Nov 30, 2008 at 5:52 PM

Regarding your first post, you are aware that most of those rules are bot going to work, right?  There is a leading slash  /   in the incoming URLs, so if you begin your patterns with ^video... then you will never match an incoming URL.

Regarding your second post, it looks like you are trying to start simple - just figure out the first rule.  Good.
Ok, have you tried the testdriver program?  What did you get?  What did you see?   What sample URLs have you sent through the system?

When I tried it, I got this:

REWRITE '/video/9zZLpZKQyJA/Arka.html' ==> '/detail.php?vid=9zZLpZKQyJA'

OK

This result means that your rule is correct for the example you've given.
If you have sent your entire log file, this means that incoming requests are not reaching the filter. Notice that the logfile has messages indicating that the IIRF has read the ini file and is running. But there is not a single message indicating that an incoming URL has been processed. Are you sending the requests to the proper port? Do you have the firewall settings configured properly?
The 404 return code can be returned when there is no connectivity to the web server. Is it possible you have pointed your browser to an incorrect domain name?
The possibilities are endless.
Let me ask you this: Can you get the URL request to work without the filter? What if you disable IIRF - can you get requests and responses to flow to IIS with IIRF disabled? If I were troubleshooting this, the first step I would take is to insure browser-to-IIS connectivity is working properly, without IIRF.
Good luck.

Nov 30, 2008 at 6:47 PM
Hi Cheeso
I have tried the testdriver.exe  for the CaseConversion I will paste what it gave me below. If you suggest me another test i can do it too.
When i request the detail.php?vid=9zZLpZKQyJA
The server gives me the correct page with no error. Only it gives 404 error when i try to rewrite the urls.




C:\inetpub>TestDriver.exe -d tests\CaseConversion

--------------------------------------------
Sun Nov 30 20:41:34 -  2364 - ReadConfig: setting LogLevel to 3
Sun Nov 30 20:41:34 -  2364 - ReadConfig: line  25: RewriteRule (rule 1)  '^/low
ercase/(.+)\.asp$'  '/lowercase-output/#L$1#E.asp'      [L]
Sun Nov 30 20:41:34 -  2364 - ReadConfig: line  27: RewriteRule (rule 2)  '^/upp
ercase/(.+)\.asp$'  '/uppercase-output/#U$1#E.asp'      [L]
Sun Nov 30 20:41:34 -  2364 - ReadConfig: line  29: RewriteRule (rule 3)  '^/One
CharLower/(.+)\.asp$'  '/OneCharLower-output/#l$1.asp'      [L]
Sun Nov 30 20:41:34 -  2364 - ReadConfig: line  31: RewriteRule (rule 4)  '^/One
CharUpper/(.+)\.asp$'  '/OneCharUpper-output/#u$1.asp'      [L]
Sun Nov 30 20:41:34 -  2364 - ReadConfig: Done reading, found 4 rules (0 errors,
 0 warnings) on 33 lines

--------------------------------------------
Sun Nov 30 20:41:34 -  2364 - Initialize: Ionic ISAPI Rewriting Filter (IIRF) v1
.2.15 final R3
Sun Nov 30 20:41:34 -  2364 - Initialize: config file 'tests\CaseConversion\Isap
iRewrite4.ini'
Processing URLs...(tests\CaseConversion\SampleUrls.txt)

Sun Nov 30 20:41:34 -  2364 - EvaluateRules: depth=0
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 1 : 2 matches
Sun Nov 30 20:41:34 -  2364 - ApplyCaseConversion: after  '/lowercase-output/thi
s.is.a.test.asp'
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Result (length 36): /lowercase-outp
ut/this.is.a.test.asp
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Last Rule
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: returning 1

REWRITE '/lowercase/This.Is.A.Test.asp' ==> '/lowercase-output/this.is.a.test.as
p'

Sun Nov 30 20:41:34 -  2364 - EvaluateRules: depth=0
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 1 : 2 matches
Sun Nov 30 20:41:34 -  2364 - ApplyCaseConversion: after  '/lowercase-output/all
_this_will_be_lowercase.asp'
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Result (length 48): /lowercase-outp
ut/all_this_will_be_lowercase.asp
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Last Rule
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: returning 1

REWRITE '/lowercase/ALL_THIS_WILL_BE_LOWERCASE.asp' ==> '/lowercase-output/all_t
his_will_be_lowercase.asp'

Sun Nov 30 20:41:34 -  2364 - EvaluateRules: depth=0
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 1 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 2 : 2 matches
Sun Nov 30 20:41:34 -  2364 - ApplyCaseConversion: after  '/uppercase-output/TES
TINGCASECONVERSION.asp'
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Result (length 43): /uppercase-outp
ut/TESTINGCASECONVERSION.asp
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Last Rule
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: returning 1

REWRITE '/uppercase/TesTiNgCaseConVerSion.asp' ==> '/uppercase-output/TESTINGCAS
ECONVERSION.asp'

Sun Nov 30 20:41:34 -  2364 - EvaluateRules: depth=0
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 1 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 2 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 3 : 2 matches
Sun Nov 30 20:41:34 -  2364 - ApplyCaseConversion: after  '/OneCharLower-output/
onlyTheFirstCharLower.asp'
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Result (length 46): /OneCharLower-o
utput/onlyTheFirstCharLower.asp
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Last Rule
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: returning 1

REWRITE '/OneCharLower/OnlyTheFirstCharLower.asp' ==> '/OneCharLower-output/only
TheFirstCharLower.asp'

Sun Nov 30 20:41:34 -  2364 - EvaluateRules: depth=0
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 1 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 2 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 3 : -1 (No match)
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Rule 4 : 2 matches
Sun Nov 30 20:41:34 -  2364 - ApplyCaseConversion: after  '/OneCharUpper-output/
Onlythefirstcharupper.asp'
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Result (length 46): /OneCharUpper-o
utput/Onlythefirstcharupper.asp
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: Last Rule
Sun Nov 30 20:41:34 -  2364 - EvaluateRules: returning 1

REWRITE '/OneCharUpper/onlythefirstcharupper.asp' ==> '/OneCharUpper-output/Only
thefirstcharupper.asp'

Sun Nov 30 20:41:34 -  2364 - DllMain PROCESS_DETACH

Coordinator
Nov 30, 2008 at 7:33 PM
Hey Karum,
ok, your TestDriver output from the CaseConversion directory looks correct.  You have confirmed for me that you have the IIRF DLL, and you are able to run the testdriver.

You said, When you request detail.php?vid=9zZLpZKQyJA The server gives me the correct page with no error. Ok, this suggests that the web server itself is working properly.



The next thing to understand is IIRF configuration.    If IIRF is configured properly, then you should see every URL request handled by IIS in the IIRF log file.  Even if IIRF does not rewrite the incoming URL, if IIRF is configured properly, there will be a log message indicating that the request had arrived. 

Do you see messages in the IIRF logfile, indicating an incoming URL request like detail.php?vid=9zZLpZKQyJA   ?

Nov 30, 2008 at 8:45 PM
When i look to logfile there is no sentence about the detail.php
I think there is a misconfiguration. What may cause this. I have only selected the dll and activated it. As told in the readme file.
Coordinator
Nov 30, 2008 at 9:54 PM
It seems there is a bad assumption or a misunderstanding on our part.
If IIRF has generated a log file, then the filter is up and running, is properly configured in IIS.

BUT ... IIRF is not receiving your requests.  Which means IIS is not receiving the requests.
Despite that, the requests are being serviced. 

How can this be?  

It is possible that IIS is not listening on the port that you think it is listening on.   You could have an Apache server listening on port 80, and IIS is listening on some other port.
In this case the requests would be serviced, but not through IIS.

Another possibility is that IIS is running on server, and there are multiple websites, and IIRF is configured only on a single website, not on the IIS server in general.  In this case the IIS website that is servicing the request is not configured with the IIRF. 

You've got to investigate this a little further.

Nov 30, 2008 at 11:17 PM
Cheeso you are %100 right! I have tried to send the same query to other subdomain (there are 3 sub domains only at here) it writes to the log file very well. There is no other webserver. This server is windows 2003. And no apache installed. I have created the 3 of the subdomains from Plesk.
When i check the other subdomains i've seen that the subdomain with problem is working as ISAPI extension. And the other subdomains are working on FastCGI mode. I have tried to change the PHP support type but it didn't helped. I have deleted the subdomain and recreated it with FastCGI mode and now it seems that this helped me. :)
Now i will try to modify all the rewrite conditions to new .ini  file.
Thank you very much Cheeso


Coordinator
Nov 30, 2008 at 11:21 PM
Terrific.
You can set the filter (IIRF) on the website, or on the web server.
If it is on the webserver, it shouild not matter how you have set up your subdomains.

I don't know all about plesk or the implications of FastCGI mode, but anyway it is worth checking into.