I am doing a web project using tomcat 7.0 . I want to redirect one page to another page.
Can I use .htaccess file in tomcat? If it can be used, how can I do?
Or can I config in web.xml ?
I'm appreciate for your helps.
Best regards,
Sokly
mod_rewrite is only an Apache module but you can use UrlRewriteFilter in Tomcat.
A rule like this should work for you in /WEB-INF/urlrewrite.xml:
<urlrewrite>
<rule>
<note>
The rule means that requests to /page-one/ will be redirected to /page-two/.
The url will be rewritten.
</note>
<from>/page-one/</from>
<to type="redirect">/page-two/</to>
</rule>
</urlrewrite>
Related
I made a TYPO3 Webpage and use the RealURL which is saved in the .htaccess.
Now I want to make this Homepage working on a IIS Webserver and have the problem that the .htaccess does not work properly, because IIS uses the web.config file.
Can anybody tell me what i have to do, so that I can use all the code of the .htaccess file?
Greetings
Simple google search:
.htaccess or .htpasswd equivalent on IIS?
https://superuser.com/questions/800261/using-htaccess-with-iis
https://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig
I have been demented with this problem for 3 days and no matter how differently I search Google or read the Helion website I cannot understand what I am doing wrong. So, I do hope that someone will be kind enough to help me.
I use a .htaccess file to create search engine friendly URLS and it has worked well for several years.
My web hosting company has now moved my site to a new Windows IIS8.5 server and the rewrites no longer work. They tell me that are using Helicon Ape (not sure what that is). But, I cannot find anything on the Helicon website that makes sense to me, as it is too technical for my old pensioners mind.
Here is a sample of the code that used to work on the old server:
# Helicon ISAPI_Rewrite configuration file
RewriteEngine on
RewriteBase /
RewriteRule ^uk-bed-breakfast-(.*)\.htm /bed-and-breakfast/region.asp\?county=$1 [QSA]
This used to turn
www.mydomain.com/bed-and-breakfast/region.asp?county=first
into
www.mydomain.com/uk-bed-breakfast-first.htm
Now all I get when I use the second URL is a 404 error.
Do I need to make any changes to comply with the newer version of IIS or Helicon Ape Rewrite, and if so what are they
After a lot of painstaking experimentation the problem has at last been solved.
It seems that with the new iis8.5 server and Helion Ape I needed to put the rewrite rules into a web.config file instead of a .htaccess file.
The new rule for the example I gave in the question is:
<rule name="Imported Rule 6">
<match url="^uk-bed-breakfast-(.*)\.htm" ignoreCase="false" />
<action type="Rewrite" url="/bed-and-breakfast/region.asp?county={R:1}" appendQueryString="true" />
</rule>
Using this system the website is at last functioning correctly.
Many thanks to all who tried to help.
Tog
is there a way to restrict crawling of HTTPS to one specific folder in robots.txt on IIS? Thanks.
One solution is that you can add <meta name="robots" content="noindex,nofollow"> to your https site.
You can create second robots.txt file, named as robots_https.txt and add all the entries to block all the content.
Then add the following lines to your .htaccess file (which is located in the root of your web hosted directory).
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^robots.txt$ robots_https.txt
Thanks guys, I think I finally found the answer in this post: http://www.jppinto.com/2010/03/automatically-redirect-http-requests-to-https-on-iis7-using-url-rewrite-2-0/ It's using URL Rewrite provided by IIS to redirect HTTPS request to HTTP, or vice versa. Or if you don't have URL Rewrite plugin installed in IIS server, you can modify Web.Config directly to add rules, as suggested in the post. Cheers.
I have an apache server running in Linux and I'm wondering how I would go about redirecting urls? I want to do this via apache not by adding a header or redirect into the individual files. The goal is to get around having to deal with .aspx
Example1:
VISITING: wwww.myserver.com/file1.aspx
Will take you to: www/myserver.com/file2.php
Example2:
VISITING: www.myserver.com/file1.aspx?command1=set&command2=set
Will take you to: www.myserver.com/file2.php?command1=set&command2=set
Without using mod_rewrite, you can simply use mod_alias, in your vhost/server config or in an htaccess file:
Redirect 301 /file1.aspx /file2.php
I would like to redirect example.com and example.com/ALL aswell as example.com/ALL/ALL, example.com/ALL/ALL/ALL etc. to example.com/offline.html, temporary. How can I do this through .htaccess ?
ALL = whatever you type
Thank you.
Redirect 302 / http://example.com/offline.html
Don't use .htaccess for this.
http://httpd.apache.org/docs/1.3/howto/htaccess.html#when
I'd recommend a proxy server.
Shovels for digging, hoes for sowing.
you just need create an HTML file called App_offline.htm then copy this file to the root of your web application
for more details have a look at:
http://msdn.microsoft.com/en-us/library/f735abw9(VS.85).aspx