Forum Moderators: phranque
How ever when I am using the equivalent static URL in the browser. I am getting the 404. I could not figure out the problem. Could any one help me. Help is highly appreciated. Thanks in advance
RewriteRule ^/appmanager/bg/main/([^/]+)/?$ /appmanager/bg/main?_nfpb=true&_pageLabel=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /appmanager/bg/main?product=?_nfpb=true&_pageLabel=([^\ ]+)\ HTTP/
RewriteRule ^/appmanager/bg/main$ [%{HTTP_HOST}...] [R=301,L]
RewriteRule ^/foobar\.html$ http://www.example.com/some_page_that_exists.html [R=301,L]
Jim
The Mod Rewrite module was enabled, However I had made the entry for RewriteLogLevel and RewriteEngine directives outside the Virtualhost directive in the config file, the rewrite engine was not working due to that. Now the Rewrite engine is working after moving the directive inside the Virtualhost directive. I had done stupid mistake in the RewriteCond rule, I removed "product=?" from the rule. The Rules I am using following rules
RewriteRule ^/appmanager/bg/main/([^/]+)/?$ /appmanager/bg/main?_nfpb=true&_pageLabel=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /appmanager/bg/main?_nfpb=true&_pageLabel=([^\ ]+)\ HTTP/
RewriteRule ^/appmanager/bg/main$ [%{HTTP_HOST}...] [R=301,L]
When I use the following static URL
[localhost...]
I am getting the 404 with out the R flag in the first rule. When I added R flag in the first rule, The static URL works.
When I use the following dynamic url.
[localhost...]
the page got displayed. However Rewrite log shows that Rewrite Condition is not matched.
When the search engine making the request with the dynamic url. The server will send the 302 Response with the new static url, then the search engine will make request again with the static URL and the request is served. When I was trying to simulate this condition through the browser using the dynamic url I did not see any change in the URL in the browser address bar. I could not figure out the problem. Jim could you kindly help me on this. Thank you son much.
You may wish to correct the DocumentRoot path if it is really wrong, or to use mod_rewrite's RewriteBase directive to "adjust" mod_rewrite to recognize and use the correct filepath.
The server error log should make the problem clear.
Jim
and the DocumentRoot to
C:/tomcat/Apache2/htdocs/appmanager/bg/main.
In the Documnent root directory i used the same rules using the .htacess file. In this case the URL in the browser looks like this.
[localhost...]
Could you help me whether i am in the right direction, your valuable help is highly appreciated. Thanks you so much.
Raj
I can't provide much more info, as I don't use Tomcat myself. You may be able to get better help from Tomcat user forums or the Tomcat or mod_jk support sites.
Jim
After adding the proxy flag, the first rule is working. Thanks you so much for your valuable suggestion. Since I am new to appache, I really need you help on this. The rules I am using are below.
RewriteRule ^/appmanager/bg/main/([^/]+)/?$ /appmanager/bg/main?_nfpb=true&_pageLabel=$1 [L,P]
RewriteCond %{THE_REQUEST}![A-Z]{3,9}\ /appmanager/bg/main?_nfpb=true&_pageLabel=([^\ ]+)\ HTTP/
RewriteRule ^/appmanager/bg/main$ [%{HTTP_HOST}...] [R=301,L]
I am getting a not matched condition when the rewriteCond is not negated, I negated the pattern to see both the rules working. When i looked in to the log file. It is looping, This happens when i use the dynamic url in the browser.
[localhost...]
Could you please help me how to avoid the looping. Thanks a lot in advance.
Raj
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /appmanager/bg/[b]main\?_nfpb[/b]=true&_pageLabel=([^\ ]+)\ HTTP/
Jim
Thanks you so much for your timely and valueable help. I have changed the second rule as the following.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /appmanager/bg/main\?_nfpb=true&_pageLabel=([^\ ]+)\ HTTP/
RewriteRule ^/appmanager/bg/main$ [%{HTTP_HOST}...] [R=301,L]
Now I am getting the looping problem for both static url and dynamic url. Could you please kindly help me where i am going wrong. Is there any other configuration parameter i need to look for. Your help would be more appreciated. Thanks a lot.
Raj
If the proxy method is looping the only other thing I can recommend trying is to use the [PT] flag instead of the [P] flag, and see if that works:
RewriteRule ^/appmanager/bg/main/([^/]+)/?$ /appmanager/bg/main?_nfpb=true&_pageLabel=$1 [PT,L]
Jim
Thanks you so much for your great help. I understand the document root what i have mentioned is misleading, I would like mention that there is not tomcat server running. The Apache server is installed under the c:\tomcat directory. I really sorry to bother you again. When i use the PT flag I am getting the message as "Your browser sent a request that this server could not understand.". Is there any other place in the config file I need to look in. You help is highly appriciated. Thanks a lot in advance.