Forum Moderators: phranque
what i'd like to know is :
1.How do I make httpd.conf file find .htaccess file ?
2.How to set the Url path for STEP 1?
3.IF everything (URL rewriting , Custom error page display , Redirecting) works with "ONLY APACHE " Why does tomcat in between cause haywire ?
For this I have the httpd.conf file consisting of the following :
STEP 1.
DocumentRoot "C:/Apache/Tomcat5.0/webapps/foodportal/jsp"
RewriteEngine On
RewriteLog "C:/Apache2.2/logs/rewrite.log"
RewriteLogLevel 3
RewriteRule /([\w-.\s]+)/([0-9]+)/?$ /FoodSourceDetailsResult.jsp?RestaurantName=$1&RRowNo=$2 [NC,L]
<Directory "C:/Apache/Tomcat5.0/webapps/">
Options FollowSymLinks
AllowOverride none
Order deny,allow
Deny from all
</Directory>
This gives the Resource not found Error 404 .
STEP 2.
Changing the Rewrite Rule to “ RewriteRule /([\w-.\s]+)/([0-9]+)/?$ [localhost...] [NC,L]”
With this rule the dynamic page is displayed when I enter [localhost...] in the address bar , But the Server does an implicit Redirect 302 and the Url is changed back to [localhost...] hence getting a partial solution .
While it should show [localhost...] .
Both the configurations were in httpd.conf file .
You need to find that code.
The problem with the internal rewrite variant of your rule (the one you want to use) may be that you need to add the [PT] flag, so that the output from mod_rewrite can be passed to your back-end as a URL, not a filepath.
I'd also suggest that you start-anchor that rule pattern, to avoid unexpected problems in the future.
Jim
After putting the [PT] flag the rewrite worked fine , and as you mentioned not using the start anchor did cause a few unexpected problems , after putting the start anchor there seem to be issues wrt loading of .css and .js files.
why these problem are because its searching for the .css , .js and image files from
[localhost...]
while it should look from [localhost...]
i tried to solve this issue using the following rules (in vain) :
RewriteRule ^/foodportal/jsp/([\w-.\s]+)/([0-9]+)/?$ /foodportal/jsp/FoodSourceDetailsResult.jsp?RestaurantName=$1&RRowNo=$2 [NC,PT]
RewriteCond %{REQUEST_FILENAME} ^(.+)\.css$
RewriteRule ^(.+)$ /foodportal/jsp$1 [NC,PT]
RewriteCond %{REQUEST_FILENAME} ^(.+)\.js$
RewriteRule ^(.+)$ /foodportal/jsp$1 [NC,PT]
RewriteRule ^/foodportal/jsp/[\w-.\s]+/([\w-.\s]+)?$ [localhost...] [NC,R=301]
Another common problem that arises when rewriting URLs is that if the links to included objects on the page are page-relative, then the browser will incorrectly resolve those relative links to canonical URLs, and request incorrect URLs. The cure is to use server-relative links or canonical URL links. That is, .css, .js and image links should start either with a slash and the full server filepath, or with "http://example.com/" plus the full server filepath. Example: Use <img src="/images/logo.gif"> or <img src="http://example.com/images/logo.gif">, not <img src="images/logo.gif">
Take a look at the request from your pages using a server heasers checker (the Live HTTP Headers add-on for Firefox is good) and take a hard look at your server error log. The correct cure for the problem depends on whether the included-object URL is correct but is being incorrectly rewritten, or the included-object URL is incorrect because rewriting the page URLs has resulted in incorrect object links on the pages.
Jim