Skip to content

Instantly share code, notes, and snippets.

@teerasej
Created January 3, 2024 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teerasej/dc764c8675f9fc1563d25913db7500eb to your computer and use it in GitHub Desktop.
Save teerasej/dc764c8675f9fc1563d25913db7500eb to your computer and use it in GitHub Desktop.
In deploying React application on apache web server which relative URL's path. You need to add a rewrite rule for routing request into that target deployed directory on the web server
# here is what you need to addd
# Avoid putting the rule into '#BEGIN ...' and '#END ...' section to prevent overwrite activity from the platform.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^vite-react-app-deploy-lab(/(.*))?$ /vite-react-app-deploy-lab/index.html [L]
</IfModule>
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@teerasej
Copy link
Author

teerasej commented Jan 3, 2024

The vite-react-app-deploy-lab is an example relative URL on the server, for example:

https://nextflow.in.th/vite-react-app-deploy-lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment