Forum Moderators: phranque
1) redirect example.mobi to www.example.mobi
2) sample.example.mobi to /index.ex with subdomain parameter invisibly
When a user enters to sample.example.mobi, the adress in the adress bar should be,
"sample.example.mobi/index.ex" but I need to take the subdomain from my code.
3) Forbid the directory listing
And there are some others.
I read many posts and answers of JDMorgan to these topics. But my problem is I have to do it with tomcat and also I have to write the rewrite rules to httpd.conf.
I write a rule for no-www redirect. But it didn't work.
May you help? What should I consider for my case? If possible can you send some code snippets. I got a lot of from the other posts actually but the question is should I have to change somathing since it is tomcat?
That's not really a very good idea, for two reasons:
First, it unnecessarily 'exposes' your filetypes to the client. This will cause problems in the future if you ever want/need/have to change your underlying technology -- say to use .php or .xhtm files.
And second, since we're talking .mobi here, including "index.ex" requires a longer URL to be typed-in if the user is trying to manually access or bookmark the page -- Not good with the inefficient text-entry on mobile devices. I would recommend making the root URL simply "/" and internally rewriting that to "/index.ex" using mod_dir's DirectoryIndex directive.
> 3) Forbid the directory listing
See Apache core Options -Indexes
The purpose of this forum is eductional. Therefore, we do not offer a "free code-writing service" here. If you would like to post the code you have tested, along with your test procedure and specific questions, we'll be very glad to help.
For example:
Jim
I solved my problem but this time another occured.
I solved it by setting
JkOptions +ForwardURICompat
parameter and the rewrite rules that I found from your comments worked.
But this time, I am not able get the parameters for the rule below.
RewriteCond %{REQUEST_URI}!^/index\.jsp
RewriteCond %{HTTP_HOST}!^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^([^.]+)\.html /index.jsp?user=%1&page=$1 [L]
For this rule,
When I typed trial.example.com/index.html, I see the index.jsp but I don't see the parameters user and page. and I am attaching the rewritelog
init rewrite engine with requested uri /index.html
rewrite /index.html -> /index.jsp?user=deneme&page=index
local path result: /index.jsp
prefixed with document_root to /usr/local/tomcat/path_to_app/ROOT/index.jsp
go-ahead with /usr/local/tomcat/path_to_app/ROOT/index.jsp [OK]
Probably, I missing a parameter again.
Thanks in advance.