0

I want to add a alias for my website. So that website.com/alias will go to a folder outside of the root folder. This folder contains a different website so i want to be able to treat this alias as if it were a subdomain.

AliasMatch  ^/subdir1/(.*)$ /var/www/otherfolder/subdir1/$1

I was hoping this would match all calls, so that website.com/subdir1/css/style.css would also be a valid path, but all of these are returning 404 errors.

How can i make the alias match a wildcard so that the entry will cover all subdirectories in the alias folder. I want to be able to do this on the apache level rather than having to do it within the .htaccess file because things are already quite complicated there so i want to bypass it if possible.

Dan Hastings
  • 3,241
  • 7
  • 34
  • 71
  • Technically any subdirectory is NOT considered a subdomain no matter where it points to. It is in fact, a subdirectory. A subdomain would be subdomain.example.com where www.example.com is the domain. – yardpenalty.com Jun 08 '17 at 20:28

2 Answers2

0

Aliases will work if you have mod_alias.so http module loaded. You need to edit httpd.conf configuration file and add below line and restart httpd.

LoadModule alias_module modules/mod_alias.so
Shubhangi
  • 2,229
  • 2
  • 14
  • 14
  • The alias already works it just isn't picking up sub directories within the alias – Dan Hastings Jun 20 '15 at 20:15
  • Did you check permissions on directories? And also did you observe any specific error in /var/log/httpd/error_log ? – Shubhangi Jun 20 '15 at 20:34
  • the error log just says it cant find files. for some reason all file paths are being stripped of the subdirectory. if i go to website.com/subdir/css it brings me to website.com/css – Dan Hastings Jun 21 '15 at 07:13
0

The issue was caused by a base URL. "/" was not correctly working as a base url. Instead i was able to solve it based on the answer here.

Set RewriteBase to the current folder path dynamically

RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]

The above was enough to solve the problem based on the post i have linked.

Community
  • 1
  • 1
Dan Hastings
  • 3,241
  • 7
  • 34
  • 71