How to create new file config using cmd [Answered]RSS

19 replies

Last post Jan 17, 2019 07:29 AM by trongthai

  • How to create new file config using cmd

    Jan 15, 2019 10:02 AM|trongthai|LINK

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

    Someone please help me.

  • Re: How to create new file config using cmd

    Jan 16, 2019 01:19 AM|Jalpa Panchal|LINK

    Hi,

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

    Regards,

    Jalpa.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 16, 2019 01:22 AM|trongthai|LINK

    Hi,

    I am using php. Is this related to cmd?

  • Re: How to create new file config using cmd

    Jan 16, 2019 06:29 AM|Jalpa Panchal|LINK

    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'}

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 16, 2019 08:23 AM|trongthai|LINK

    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?

  • Re: How to create new file config using cmd

    Jan 16, 2019 09:20 AM|Jalpa Panchal|LINK

    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'}

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 16, 2019 09:43 AM|trongthai|LINK

    Error

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

  • Re: How to create new file config using cmd

    Jan 16, 2019 09:48 AM|Jalpa Panchal|LINK

    How you run the command?

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

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 16, 2019 09:53 AM|trongthai|LINK

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

    http://prntscr.com/m7v1us

  • Re: How to create new file config using cmd

    Jan 17, 2019 01:40 AM|Jalpa Panchal|LINK

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

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

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 17, 2019 01:58 AM|trongthai|LINK

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

  • Re: How to create new file config using cmd

    Jan 17, 2019 02:01 AM|Jalpa Panchal|LINK

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

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 17, 2019 02:03 AM|trongthai|LINK

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

  • Re: How to create new file config using cmd

    Jan 17, 2019 02:05 AM|Jalpa Panchal|LINK

    which version of os you are using?

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 17, 2019 02:07 AM|trongthai|LINK

    I'm using IIS7

  • Re: How to create new file config using cmd

    Jan 17, 2019 05:14 AM|Jalpa Panchal|LINK

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

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 17, 2019 06:41 AM|trongthai|LINK

    I'm using windows server 2016

  • Re: How to create new file config using cmd

    Jan 17, 2019 06:51 AM|Jalpa Panchal|LINK

    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'}

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: How to create new file config using cmd

    Jan 17, 2019 06:54 AM|trongthai|LINK

    Thank you somuch!
    It worked.
    Thanks again!

  • Re: How to create new file config using cmd

    Jan 17, 2019 07:29 AM|trongthai|LINK

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

    I tried appcmd but got an error