Search code examples
apache.htaccessmod-rewriteisapi-rewrite

Unable to Rewrite directory with fullstop in name to another


I need to rewrite a directory and all is contents to a new directory however I am having issues I think due to the source directory having a full stop in it.

i.e.

http://example.com/1.0/ to http://example.com/newfolder/

Here is the rule I am trying

RewriteEngine On
RewriteBase /

RewriteRule ^1\.0$ http://example.com/newfolder/ [NC,R=301,L]

Solution

  • You can use:

    RewriteEngine On
    
    RewriteRule ^1\.0(/.*)?$ http://example.com/newfolder$1 [R=301,L]
    

    This will redirect /1.0/anything to /newfolder/anything