Skip to content

Instantly share code, notes, and snippets.

@tarikmanoar
Last active June 4, 2024 02:03
Show Gist options
  • Save tarikmanoar/2bcef1f57a9d6d705422d9595568bd61 to your computer and use it in GitHub Desktop.
Save tarikmanoar/2bcef1f57a9d6d705422d9595568bd61 to your computer and use it in GitHub Desktop.
Helpful .htaccess
// .htaccess for park main domain to a dir
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dir/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ dir/ [L]
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
//VUE Engine
// .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
// Or
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
// For Nginx server
location / {
try_files $uri $uri/ /index.html;
}
or
location / {
try_files $uri $uri/ =404; " with " try_files $uri $uri/ /index.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment