简体   繁体   中英

Apache 2.4: RegEx for Alias in httpd conf

Below is the Alias aI have in my apache 2.4 httpd conf file For every release we'll update the version number and am trying to use a regex to catch the changes instead of manually changing the version number every time

For example our current version is Passport14200(14 is the year number and 2 is for second release in 2014) our next release in this year will be Passport14300( 3rd release in 2014) and our first release in 2015 will be Passport15100

This is how my httpd conf file looks like now

Alias /Passport14200 C:/Passport/tomcat/webapps/?Passport
<Directory C:/DC/Passport/tomcat/webapps/Passport>
    Require all denied
    <FilesMatch "\.(gif|jpe?g|jpg|png|js|css|ico)$">
        Require all granted
    </FilesMatch>

    ExpiresActive On
    ExpiresByType image/gif "access plus 10 years"
    ExpiresByType image/png "access plus 10 years"
    ExpiresByType text/css "access plus 10 years"
    ExpiresByType text/javascript "access plus 10 years"
    ExpiresByType application/javascript "access plus 10 years"
</Directory>

Am wondering is there a way to alias with a regex so that it catches Passport[\\d{5}]?

I am new to the Regularexpressions, can someone please help me with this?

Every Alias points to a same folder C:/DC/Passport/tomcat/webapps/Passport

This will match any alias starting with /Passport to the same folder.

AliasMatch ^/Passport.* C:/DC/Passport/tomcat/webapps/Passport
<Directory C:/DC/Passport/tomcat/webapps/Passport>
    Require all denied
    <FilesMatch "\.(gif|jpe?g|jpg|png|js|css|ico)$">
        Require all granted
    </FilesMatch>

    ExpiresActive On
    ExpiresByType image/gif "access plus 10 years"
    ExpiresByType image/png "access plus 10 years"
    ExpiresByType text/css "access plus 10 years"
    ExpiresByType text/javascript "access plus 10 years"
    ExpiresByType application/javascript "access plus 10 years"
</Directory>

If you want to be sure that there are only 5 digits after Passport - use AliasMatch ^/Passport\\d{5} C:/DC/Passport/tomcat/webapps/Passport

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM