locked
How to create new file config using cmd RRS feed

  • Question

  • User-1727828520 posted

    I want to create a rewrite url in cmd but I don't have the web.config file yet.

    Someone please help me.

    Tuesday, January 15, 2019 10:02 AM

Answers

  • User-848649084 posted

    hi,

    No need to create web.config file in iis ,it will automatically create config file.

    try below command:

    Add-WebConfigurationProperty -pspath 'iis:\sites\php2' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.website.com' ;patternSyntax='Wildcard';stopPrcessing='True'}

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, January 16, 2019 6:29 AM
  • User-848649084 posted

    Click on search and type powershell and right click on it and select run as administator and open it.

    Run this command:

     Add-WebConfigurationProperty -pspath 'iis:\sites\php2' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.website.com' ;patternSyntax='Wildcard';stopPrcessing='True'}

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, January 17, 2019 6:51 AM

All replies

  • User-848649084 posted

    Hi,

    Could you please tell us which type of application you are using(like html,asp.net,php)?

    Regards,

    Jalpa.

    Wednesday, January 16, 2019 1:19 AM
  • User-1727828520 posted

    Hi,

    I am using php. Is this related to cmd?

    Wednesday, January 16, 2019 1:22 AM
  • User-848649084 posted

    hi,

    No need to create web.config file in iis ,it will automatically create config file.

    try below command:

    Add-WebConfigurationProperty -pspath 'iis:\sites\php2' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.website.com' ;patternSyntax='Wildcard';stopPrcessing='True'}

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, January 16, 2019 6:29 AM
  • User-1727828520 posted

    I tried to use below command:

    appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].match.url:"(client*)""

    But it reported an error:

    The configuration section "system.webServer / rewrite / rules / [name = 'abc']. Match.url: (. *)" Is unknown. To display help, replace with?

    Wednesday, January 16, 2019 8:23 AM
  • User-848649084 posted

    Hi,

    Try to access this command:

     

    Add-WebConfigurationProperty -pspath 'iis:\sites\php2' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.website.com' ;patternSyntax='Wildcard';stopPrcessing='True'}

    Wednesday, January 16, 2019 9:20 AM
  • User-1727828520 posted

    Error

    Add-WebConfigurationProperty 'is an internal command or external command,
    It is not recognized as an operable program or batch file.

    Wednesday, January 16, 2019 9:43 AM
  • User-848649084 posted

    How you run the command?

    as you can see i am able to create rewrite rule without facing any error.

    Wednesday, January 16, 2019 9:48 AM
  • User-1727828520 posted

    I copied your statement and just changed the site name and rule name.

    http://prntscr.com/m7v1us

    Wednesday, January 16, 2019 9:53 AM
  • User-848649084 posted

    This is power-shell command. could you use power-shell ?

    https://docs.microsoft.com/en-us/powershell/module/webadministration/add-webconfigurationproperty?view=win10-ps

    Thursday, January 17, 2019 1:40 AM
  • User-1727828520 posted

    I tried running the example on that page but it still received the same error as above.

    Thursday, January 17, 2019 1:58 AM
  • User-848649084 posted

    You face same error when you try to run on powershell window?

    Thursday, January 17, 2019 2:01 AM
  • User-1727828520 posted

    Yes, It's like the error I sent you yesterday.

    Thursday, January 17, 2019 2:03 AM
  • User-848649084 posted

    which version of os you are using?

    Thursday, January 17, 2019 2:05 AM
  • User-1727828520 posted

    I'm using IIS7

    Thursday, January 17, 2019 2:07 AM
  • User-848649084 posted

    could please tell us your operating system version(windows 10,server 2016)?

    Thursday, January 17, 2019 5:14 AM
  • User-1727828520 posted

    I'm using windows server 2016

    Thursday, January 17, 2019 6:41 AM
  • User-848649084 posted

    Click on search and type powershell and right click on it and select run as administator and open it.

    Run this command:

     Add-WebConfigurationProperty -pspath 'iis:\sites\php2' -filter "system.webServer/rewrite/rules" -name "." -value @{name='Redirect www.website.com' ;patternSyntax='Wildcard';stopPrcessing='True'}

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, January 17, 2019 6:51 AM
  • User-1727828520 posted

    Thank you somuch!
    It worked.
    Thanks again!

    Thursday, January 17, 2019 6:54 AM
  • User-1727828520 posted

    So if using powershell, what is the new web creation command?

    I tried appcmd but got an error

    Thursday, January 17, 2019 7:29 AM