You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,6 +172,51 @@ yarn build
172
172
173
173
The built application will be in the `dist/` directory.
174
174
175
+
### 🌐 Deploying to cPanel (Apache)
176
+
177
+
Code Executives is a **Single Page Application (SPA)** that uses client-side routing via React Router. When deployed on a traditional Apache/cPanel host, you need to tell Apache to serve `index.html` for every URL so that React Router can handle navigation. Without this step, directly visiting any URL (e.g. `https://codexecutives.com/javascript`) will return a **404 error** because Apache looks for a physical file at that path.
178
+
179
+
**This repository already includes the required `.htaccess` file** (`public/.htaccess`) which Vite automatically copies to `dist/` on every build.
180
+
181
+
#### Step-by-step cPanel deployment
182
+
183
+
1.**Build the application**
184
+
185
+
```bash
186
+
npm run build
187
+
```
188
+
189
+
The `dist/` folder now contains the complete production bundle, including the `.htaccess` file.
190
+
191
+
2.**Upload `dist/` contents to your public_html directory**
192
+
193
+
Using cPanel's File Manager or FTP, upload **all files and folders** inside `dist/` (not the folder itself) to your domain's `public_html` directory (or the sub-directory you are deploying to).
194
+
195
+
> ⚠️ Make sure to upload hidden files as well — the `.htaccess` file starts with a dot and can be invisible in some FTP clients. Enable "Show Hidden Files" in cPanel File Manager.
196
+
197
+
3.**Verify `mod_rewrite` is enabled**
198
+
199
+
The `.htaccess` relies on Apache's `mod_rewrite` module. Most cPanel hosts have this enabled by default. If you still see 404 errors after uploading, contact your host to confirm `mod_rewrite` is active.
200
+
201
+
4.**Test direct URL access**
202
+
203
+
Open your browser and navigate directly to a deep URL such as `https://yourdomain.com/javascript` or `https://yourdomain.com/git`. The page should load correctly via React Router.
204
+
205
+
#### How the `.htaccess` works
206
+
207
+
```apache
208
+
Options -MultiViews
209
+
RewriteEngine On
210
+
RewriteCond %{REQUEST_FILENAME} !-f
211
+
RewriteCond %{REQUEST_FILENAME} !-d
212
+
RewriteRule ^ index.html [QSA,L]
213
+
```
214
+
215
+
- Requests for **real files** (JS/CSS chunks, images, fonts) are served directly.
216
+
- All other requests are **internally rewritten** to `index.html`, letting React Router decide what to render.
217
+
218
+
> **No Node.js server is required.** The application is a fully static bundle that works with any web server capable of serving static files.
0 commit comments