Created
January 3, 2024 06:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
vite-react-app-deploy-lab
is an example relative URL on the server, for example: