I currently have a rewrite.config file with the following: RewriteRule ^/abc /docs. This successfully directs clients to the docs webapp, but I would still like the client to see localhost/abc in their browser.
In Apache mod_rewrite, this would be handled by simply adding [PT] to the end of the rewrite rule.
Any suggestions?
Thanks,
Brandon
I would suggest using the Tuckey UrLRewriteFilter. It appears to have better documentation and offer more flexibility than Tomcat's Rewrite value.
Related
On centos 6, tuleap 9.1, after installation I am only able to access the main page on http, the rest is not available because each links are root on https. Is there's a way to deactivate ssl completely?
I installed all, now can access to the first presentation page, but only if I use http and not https. Problem all the rest of the link of page ( create account, connexion etc...) redirect to https. I already try to deactivate https without success.
Can anyone can help to disable https and is stopping using ssl definitely can generate issue when using this tool?
You could force your website to only load on HTTP through your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://www.{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
I've included www in the Rewrite, if you don't want that then you can remove that section. I've also set R=302so that it is a temporary redirect. Set this to R=301 once you know it is working, as that will make it permanent.
Make sure you clear your cache before you test this.
I want to redirect one URL to another without changing the Browser URL
www.example.com/abc/(.*).xml should redirect to www.example.com/abc/xyz/index.htm?file=$1
But the Browser should display www.example.com/abc/(.*).xml
You can use a RewriteRule:
RewriteEngine On
RewriteRule /abc/(.*)\.xml$ /abc/xyz/index.htm?file=$1 [L]
Make sure you have mod_rewrite enabled and put this either in your VirtualHost config, or in a .htaccess file in your DocumentRoot
As Constantine posted on the accepted solution, the [P] flag is dangerous as it converts the server as a proxy.
See [this]: https://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever?noredirect=1&lq=1
P = Proxy. Forces the rule to be handled by mod_proxy. Transparently provide content from other servers, because your web-server fetches it and re-serves it. This is a dangerous flag, as a poorly written one will turn your web-server into an open-proxy and That is Bad.
OK, I'm looking to use mod rewrite to write seo friendly urls for my site. It works fine on my xampp local testing server. However, I'm having problems when trying to put it live, it doesn't seem to work at all.
Here's what I've written in my htaccess file:
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9]+)$ category.php?location=$1
So the idea is to change mysite.com/category.php?location=londonto mysite.com/category/london.
Initially I though it may be an issue with the ability to mod rewrite being switched on on GoDaddy's end, so I contacted GoDaddy to see if it that was the case and their response was that: "Mod_rewrite is an Apache Web server module installed on all of our Linux servers by default; it does not have to be installed or enabled. Our Linux hosting accounts support most mod_rewrite functions. Because enabling mod_rewrite is handled at a global level, you do not need to enable it in your httpd.conf file. You only need to add the desired code to the body of your .htaccess file."
And they bascially implied that the error is not with them and with my code. I'm not very experienced with mod rewrites and it seemed to work fine when I wrote it like this on other servers. Is there something special you have to write with godaddy? Am I missing something? Thanks!
Is that all in your htaccess file? What error do you get when visiting a desired URL, is it a 500 Internal Server error?
What I usualy add by default is an If-statement:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^category/([a-zA-Z0-9_-]+)$ category.php?location=$1 [L]
</IfModule>
By the way, note the _- at the end of the charset in the rule, for instance New York has a SEF version which is new-york, category/new-york would fail in your RewriteRule.
I'm developing a webapp and for the static files I'm simply using apache at localhost while the backend is on a couchdb instance running at localhost:5984.
The webapp interacts with files from the backend all the time. So what is happening when trying to test on apache all file requests to localhost:5984 are getting blocked due the cross-domain policy so the only way to get that working is starting the browser by setting flags to ignore that.
But again I get stuck when trying to test the app on mobile such ipad or iphone.
Currently I have this on my .htaccess file.
RewriteEngine on
# these are 302 http redirections instead of serving as a proxy
RewriteRule auth http://localhost:5984/auth [L]
RewriteRule db/([\s\S]+) http://localhost:5984/db/$1 [L]
RewriteRule send/([\s\S]+) http://localhost:5984/send/$1 [L]
# these are just redirections to static files and work great
RewriteRule ^([a-z/.]+) _attachments/$1 [L]
RewriteRule ^$ _attachments/ [L]
As you can see I have really no idea on how to deal with apache configuration unfortunately.
But what is happening right now is that for some of these rules apache is simply redirecting the page instead of provide it as a proxy server which causes the issue with cross-domain.
Also on the first auth rule I send POST and DELETE requests which as a redirection instead of proxy it won't pass the data being POSTed through.
So what I would like to achieve is to activate some kind of feature (if it exists) which will make apache simply render the page as it was on the localhost domain instead of redirect it. (I named this a a proxy, but perhaps that's not even the right term, sorry for any mistake committed with the nomenclatures).
Is is possible to achieve such action?
Thanks in advance
Have a look at these links / options:
[P] flag:
http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
http://httpd.apache.org/docs/current/rewrite/proxy.html
mod_proxy (possibly -- but I think #1 should be enough if it's on the same server):
http://httpd.apache.org/docs/current/mod/mod_proxy.htm
I have a struts app running on Apache front end of Tomcat via mod-jk.
I am trying to use mod-rewrite to clean some of the action urls generate by struts.
Example: rewrite (works fine)
http://www.demo.com/context/user.do?action=aboutus to http://www.demo.com/context/aboutus using
RewriteRule ^/msn/aboutus$ /msn/user.do?action=aboutus [PT,L].
Problem: I'd like to rewrite the http://www.demo.com/context/user.do?action=home to http://www.demo.com (homepage)
I tried this
RewriteRule ^/$ /context/userdo?action=home [PT,L] which does not work.
FYI
All the css,js and links are on relative path.
DirectoryIndex is on index.html (Does it change mod-rewrite behaviour?)
Tomcat Version 5.5, Application deploy via exploding the WAR file in public_html/context/ folder (multiple deployment)
URLrewrite filter does not help to remove the context name according to this.
Logs
I tired to have a look at the log file (snapshots) which doesn't give any warning error messages.
(3) applying pattern '^/$' to uri '/context/jsps/images/abc.png'
(3) applying pattern '^/abc/aboutus$' to uri '/abc/jsps/images/abc.png'
(3) applying pattern '^/abc/home$' to uri
'/abc/jsps/images/abc.png'
Anyone can give me some ideas what went wrong? and how can I solve that issue?
I think in your case of rewriting ^/$ it is mod_jk that is taking precedence over mod_rewrite rules since using mod_jk you are forwarding everything eg: /* to Tomcat from Apache. I will suggest using URLRewriteFilter within your Tomcat app to achieve these URL rewrites properly.