web.config not working with WordPress permalinks in sub folder - wordpress

I have WP installed on an IIS server in the root folder. This works with pretty permalinks.
There is also another wordpress install at /development which uses the following web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress1" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule></rules>
</rewrite>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
</staticContent>
</system.webServer>
</configuration>
However, pretty permalinks are not working on this site in the subfolder
The home page works however of this sub folder and when plain permalinks are selected
Any ideas why?

The answer as pee2pee says, is to place that line in the code.
<remove name="YourRuleName"/>
To do this you must first look at the web.config file of the root and look for this line.
<rule name = "YourRuleName" patternSyntax = "Wildcard">
and then copy the line in the web.config file of your directory or subfolder, changing "YourRuleName" to the name you found in the web.config file of the root just above the first tag.
Then, your web.config file of the sub folder should look like
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<remove name="YourRuleName"/>
<rule name="YourSubFolderRuleName" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule></rules>
</rewrite>
</system.webServer>
</configuration>
I hope it is helpful, for me it has been.

Ensure the root folder (serving the primary site) and the subfolder (where the secondary or /shop resides) each have a unique web.config file.
In your subfolder’s web.config file you need to remove the rule that was set in the root folder. In our case, the WordPress rewrite rule set in the root folder was called “PrimarySite”, so in the subfolder’s web.config we have:
<remove name="PrimarySite"/>
And that’s all it took to get things working. Simple, eh?

As of WP 5.9 (but I am sure way back years and versions) there is no need to add web.config manually.
In case IIS rewrite module is installed (whichi is a prerequisite) when you modify Settings/Permalink, WP automatically emits web.config into the root of your site.
It even writes to the GUI a warning message, to revoke write access from web.config.
If IIS rewrite module is not installed, all of this above is not possible, neither manually, so WP will include the /index.php/ fragment in the path. If you overwrite this setting with a custom permalink setting, then the links will adopt (so will not contain the /index.php/ fragment, but because of lack of rewrite facility IIS will give 404.

Related

WordPress permalinks rewrite on iis7

I spend a lot of time in looking for solution, so you are my last hope before giving up :)
On my localhost iis7 i set custom permalinks http://sitename/%sample-post%/ with rewrite mode installed.
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php"/>
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="WordPress: http://tip4u03" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule></rules>
</rewrite>
</system.webServer>
</configuration>
Its work only in wwwroot directory. Outside of wwwroot directory, its return 404 template page. Same issue on my shared iis7 server (VPS)
I solved the issue !!!
The problem was't with site location, it was because the permalinks are in Hebrew language. I added the following condition to wp-config file
if (isset($_SERVER['UNENCODED_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
}
according to this link: Wordpress Hebrew permalinks
Finally its work !

Angular 2 Visual Studio Setup Problems

I followed the Angular2 VS setup from this page-
https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html
The issue is that http://localhost:56428/ gives a 403 (forbidden) error, and the only way to access my index is to navigate to http://localhost:56428/src/index.html.
This is not ideal, and doesn't even work because requests to system.js and other files on this page go straight to the web root.
I'm not sure if I missed a step here but I don't think this is what they intended. How do I make src/ servable at /?
ANSWER FOUND AT
.net web application change root directory
I don't know why the angular site does not mention that.
Try to add base tag:
The tag specifies the base URL/target for all relative URLs in
a document
.
http://www.w3schools.com/tags/tag_base.asp
ANSWER FROM
.net web application change root directory
<configuration>
<system.web>
...
<urlMappings enabled="true">
<add url="~/" mappedUrl="~/src/index.html" />
</urlMappings>
</system.web>
...
<system.webServer>
...
<rewrite>
<rules>
<rule name="Redirect everything to root" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/src/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
...
</configuration>
Have you marked your index.html as application start up page?
If not, right click on index.html and click on "Set As Start Page".

IIS-7 wildcard redirect web.config with wordpress

Have a wordpress site running on IIS 7 shared server that is replacing an html site. I have only experience with apache so....
Need to modify the web.config file for the following
Add wildcard redirect to redirect all old site .htm pages to corresponding wordpress page. so /about.htm would got to /about and /contact-us.htm would go to /contact-us
Also need to add some specific redirects that will work within wordpress
For example:
http://sitename.com/articles redirects to http://sitename/news-and-events
Below is the default web.config file that was installed...and is working as far as general wordpress functionality.
I have tried some suggestions I found here that were related to removing .aspx but either they seem to have no effect or caused 500 error. Also as I am not sure if I am placing the rules in the right place/order within the file hierarchy.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress: http://sitename.com" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule></rules>
</rewrite>
</system.webServer>
</configuration>

index.php shown up in every link

my problem is that my link shows (index.php) in every link like this
(www.mysite.com/index.php/postname)
and i want to show it like this
(www.mysite.com/postname)
but i want to remove that (index.php) from my links so how to do that?
i m using
(iis) 7.5 and (wordpress) 4.01
i try so many things but did not work so how to solve it?
and i cant also see web.config
but i can see (wp.config) so are they same?
You need to log into wordpress admin and go to permalinks and change
Custom Structure to: /%postname%/
Do not add the domain or index.php
if your'e running IIS you need to follow instructions on this link:
http://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite
or you can just
add web.config file to the root folder (where the WP install is) containing
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Then you can adjust your permalinks to your custom setup in the admin panel.

Wordpress permalinks on IIS?

I am using WordPress on Windows 7 IIS to develop. I am uploading images in WordPress for a blog post. The image displays fine on the web site but as soon as I enable permalinks the images no longer work and any future images uploaded I get back an error:
HTTP Error 500.50 - URL Rewrite Module Error.
The page cannot be displayed because an internal server error has occurred.
I am not sure why this would be happening, here is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
As soon as I turn off my permalinks and use the default it works, does anyone know why this could be?
The image issue was a permission issue, but simply setting it manually
on the original image file or parent folder is inadequate. The
behavior of WordPress is that it writes the original file using IUSR
to a temporary system directory that is defined in the PHP.ini file.
This temp folder does not have IIS_IUSRS permissions on it, so when
windows moves this file from the temp folder to the application's
upload folder, its final home, IIS_IUSRS only has read permissions, so
the permissions are not inherited from the file's parent folder.
To fix this, there are two solutions.
Change the permissions on the temp folder giving IIS_IUSRS write/modify.
Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.
Here is a good source detailing the problem:
http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/
I chose to move the temp folder in my PHP.ini to
C:\inetpub\temp\uploads and also give it permissions. After uploading
an image in wp-admin, I was able to access the image (original, not
resized) from a browser wihout the 500.50 error.
From source
There's a slightly different web.config at Using Permalinks « WordPress Codex as well as other options for Permalinks without mod rewrite on Windows.
To help other users this issue is due to permissions in IIS and a fix is also here:
http://forums.iis.net/t/1159252.aspx
use this below mention RULEs in your web.config file ..
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false"/>
<action type="None"/>
</rule>
<rule name="Redirect Image to HTTP" stopProcessing="true">
<match url=".*\.(gif|jpg|jpeg|png|css|js)$" ignoreCase="true"/>
<action type="Rewrite" url="{R:0}"/>
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="." ignoreCase="false"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true"/>
</conditions>
<action type="Rewrite" url="/index.php"/>
</rule>

Resources