Apache rewrite based on subdomain

You should have a look at the URL Rewriting Guide from the apache documentation. The following is untested, but it should to the trick: RewriteCond %{HTTP_HOST} ^([^.]+)\.blah\.domain\.com$ RewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] This only works if the subdomain contains no dots. Otherwise, you’d have to alter the Regexp in RewriteCond to match any character which should … Read more

Redirect requests only if the file is not found?

# If requested resource exists as a file or directory, skip next two rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) – [S=2] # # Requested resource does not exist, do rewrite if it exists in /archive RewriteCond %{DOCUMENT_ROOT}/archive/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/archive/$1 -d RewriteRule (.*) /archive/$1 [L] # # Else rewrite requests … Read more

How to setup apache server for React route?

Change the VirtualHost configuration (typically found in /etc/httpd/conf.d\vhosts.conf) by adding the following Rewrite* lines: <VirtualHost *:8080> ServerName example.com DocumentRoot /var/www/httpd/example.com <Directory “/var/www/httpd/example.com”> … RewriteEngine On # Don’t rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ … Read more

How to make static content on Apache be cached by browser and not checked for freshness with every request?

Expires module in Apache solves this a2enmod expires it needs to be loaded in server config, and set up in .htaccess (or in server config). With an Expires header, the resource is only requested the first time. Before the expiration date, subsequent requests are fulfilled from browser cache. After the specified time expires and the … Read more

CSS, JS and images do not display with pretty url

When you use relative url’s, the browser will dynamically create a complete url by using the url of the resource it loaded. In other words: It uses the url as it is displayed in the address bar. In your case (www.domain.com/subfolder/index.php/key) it tries to load any relative url relative to www.domain.com/subfolder/index.php/. Your resources are however … Read more