I've transferred my IIS6-based website to IIS7. It uses ISAPI Rewrite. I want to use the built in IIS7 rewrite engine. I have the following code in my httpd.ini file:
[ISAPI_Rewrite]
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]
RewriteRule ^(.*)$ http://www.workcity.co.il/$1 [R,R=301]
RewriteRule /([^/.?]+) /sc.asp?p=$1 [I,L]
RewriteRule /products/([^/.?]+) /sp.asp?p=$1 [I,L]
RewriteRule /מוצרים/([^/.?]+) /sp.asp?p=$1 [I,L]
But it dosen't work in IIS7 Rewrite Engine.
What is different in the IIS7 rewrite engine between ISAPI Rewrite, and how can I fix it?
Thanks.
Importing Apache mod_rewrite Rules
IIS Uses a seperate downloadable plug that will first need intalling.
Once that is complete, you just need to convert the RegEx ISAPI rules above to work with IIS7.
The RegEx principles and logic will be very similar, you'll just need to convert the syntax.
Theres a lot of info on the IIS.net site that will help you convert the rules.
http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
I hope that helps
Related
I've been given a request from a client to ensure all visits to their site are to lowercase URLs following an external SEO audit.
For example they'd like www.example.com/How-We-Help to redirect with a 301 code to www.example.com/how-we-help
Their site is hosted on WPEngine - I know this would be a simple thing to do using htaccess rules but htaccess has been deprecated on WPEngine for a little while now.
Example htaccess rule
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
I've read that it is possible to create a similar rule with Nginx rewrites but my knowledge is limited and WPEngine support weren't much help.
Is a way to do this using Nginx rewrites? If so, what rules need to be in place?
I need to translate htaccess rewrite rule for a IIS web server, can you help me with the sintax? for example:
RewriteCond %{QUERY_STRING} ^orderby=([0-9]+)&pagesize=([0-9]+)&pagenumber([0-9]+)$
RewriteRule ^[OLD-SLUG]$ https://www.[DOMAIN].it/[NEW-SLUG]? [R=301,L]
Or:
RewriteRule ^[OLD-SLUG]$ - [G]
Thanks
Many PHP applications currently ship with rewrite rules as part of their .htaccess file. These rules tell Apache's mod_rewrite how and when to rewrite incoming requests. The IIS URL Rewrite module can read these rules and translate them into URL Rewrite rules.
For more information about importing Apache mod_rewrite rules, see: Importing Apache mod_rewrite Rules.
To allow video to be played in element from my website, but not allowing it through direct link, I created .htaccess in a sub-directory with the source videos, and nothing else. with the below code:
RewriteEngine On
RewriteCond %{REQUEST_URI} \.(mp4|mp3|avi)$ [NC]
RewriteCond %{HTTP_REFERER} !^http://sample.com/.*$ [NC]
RewriteRule ^.* - [F,L]
I need to do the same with .NetCore server, but do not know how?
Any help. thanks.
I think a simple approach to this problem would be an application level solution using .NET Core by simply denying requests based on referrer in your controller by checking referrer header.
If you run .NET Core application(s) using IIS, then you could use IIS rewrite rules specifying them in web.config, and this approach would look similar to .htaccess one. Several examples.
The application level solution might be a little bit slower, however has better visibility to developers and is easier to maintain.
friends. I'm creating an .htaccess file with rewrite rules. It's working fine in localhost, but on the live, server it's not working. My hosting uses a Window server.
I wrote this Rule in my .htaccess file:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
By default, IIS does not support .httacces and Apache mode_rewrite rules. To achieve this, you will have to install Helicon Ape addon along with IIS. Helicon Ape offers support for the Apache .htaccess and .htpasswd configuration files in Microsoft IIS.
With Helicon Ape you can use modules, like mod_rewrite, mod_proxy, mod_auth, mod_gzip, mod_headers, mod_cache, mod_expires, mod_replace and others under single IIS addon. Single website license for Helicon Ape will cost you $47 one time.
If you want to have free alternative, you can go with native IIS URL Rewrite Module. Microsoft URL Rewrite module offers similar functionality like Apache mod_rewrite module with the help of web.config file. You can simply install this module and import your .httacces rules to IIS web server. This module also lets you convert the existing Apache mod_rewrite rules to IIS URL rewrite rules and store them to web.config automatically. For more information, refer to following tutorial.
https://manage.accuwebhosting.com/knowledgebase/2415/How-to-Enable-modrewrite-on-IIS-Web-Server.html
The actually URL which my app uses is:
http://site.com/search.php?search=iPhone
but I would like it to be possible to achieve the same with
http://site.com/iPhone
I have no experience of rewrite rules, how can I set this up?
The solution has worked but the new URL is displayed in the address bar. I thought it would have been possible to set this up so that it appears as though the page location is
http://site.com/iPhone
without changing to display
http://site.com/search.php?search=iPhone
Is this possible? Thanks.
Create a file called .htaccess in the root of your website and put this in it.
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^(.*) search.php?search=$1 [R]
Should do the trick.
I would suggest however that you make it a bit more specific, so maybe require the user of a search directory in your url. eg instead of mysite.com/IPhone use mysite.com/search/IPhone which would work like
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^search/(.*) search.php?search=$1 [R]
This makes it easier to have normal pages that arnt redirected, such as about us or a basic homepage.
As Chris says, this is not PHP but Apache that does this, and whether it works can depend on your hosting setup.
You need to specify something like this in your .htaccess file:
RewriteEngine on
RewriteRule /(.*) /search.php?search=$1
Check also:
mod_rewrite: A Beginner's Guide to URL Rewriting
Module mod_rewrite, URL Rewriting Engine
Rewrite rules aren't part of PHP as far as I'm aware, but Apache (specifically mod_rewrite) or whatever server you're using. For Apache, you need on the server to have a file called .htaccess, and in it put something like:
RewriteEngine on
RewriteRule ^(\w+)/?$ /index.php?search=$1
^(\w+)/?$ is a regular expression - it matches any word of 1 or more characters, followed by a / maybe. So it changes site.com/iPhone into site.com/index.php?search=iPhone. Sound about right?