File Manager
Editing: .htaccess
RewriteEngine On # ── API exception — MUST come first before any redirects ───────────────────── # Cordova CORS preflight cannot follow redirects. # Any request to /api/* bypasses www and HTTPS rewrites entirely. RewriteCond %{REQUEST_URI} ^/api/ [NC] RewriteRule ^ - [L] # ── Redirect non-www to www with HTTPS ─────────────────────────────────────── RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301] # ── Redirect www HTTP to HTTPS ──────────────────────────────────────────────── RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301] # ── Remove .php extension from URLs ────────────────────────────────────────── RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^\.]+)$ $1.php [L] # ── Named routes ───────────────────────────────────────────────────────────── RewriteRule ^home$ index.php [L] RewriteRule ^profile/([a-zA-Z0-9_-]+)$ profile.php?user=$1 [L,QSA] RewriteRule ^products$ allproducts.php [L] RewriteRule ^add-product$ addproduct.php [L] RewriteRule ^process-product$ processproduct.php [L] RewriteRule ^product-requests$ add_request.php [L] RewriteRule ^process-request$ process_request.php [L] RewriteRule ^requests$ requests_page.php [L] RewriteRule ^about$ about-us.php [L] RewriteRule ^privacy-policy$ privacy-policy.php [L] RewriteRule ^terms-and-conditions$ terms-and-conditions.php [L] RewriteRule ^maintenance$ maintenance.php [L] RewriteRule ^all_accounts$ all_accounts.php [L] RewriteRule ^offline$ offline.php [L] RewriteRule ^login$ login.php [L] RewriteRule ^register$ register.php [L] RewriteRule ^contact$ contact.php [L] RewriteRule ^sell$ sell.php [L] RewriteRule ^checkout$ checkout.php [L] RewriteRule ^order-history$ order_history.php [L] RewriteRule ^faq$ faq.php [L] RewriteRule ^blog$ blog.php [L] # ── Clean URL patterns ──────────────────────────────────────────────────────── RewriteRule ^products/([a-zA-Z0-9-]+)$ allproducts.php?category=$1 [L,QSA] RewriteRule ^regions/([a-zA-Z0-9-]+)$ allproducts.php?region=$1 [L,QSA] RewriteRule ^blog/([a-zA-Z0-9-]+)$ blog_post.php?slug=$1 [L,QSA] # ── Legacy redirect: /index.php → /home ────────────────────────────────────── RewriteCond %{THE_REQUEST} \s/index\.php [NC] RewriteRule ^ /home [R=301,L] # ── Legacy redirect: old category URLs ─────────────────────────────────────── RewriteCond %{THE_REQUEST} \s/allproducts\.php\?category=([^\s&]+) [NC] RewriteRule ^ /products/%1? [R=301,L] # ── Legacy redirect: old .php URLs ─────────────────────────────────────────── RewriteCond %{THE_REQUEST} \s/([^/]+)\.php [NC] RewriteRule ^ /%1 [R=301,L] # ── Compression ────────────────────────────────────────────────────────────── <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json </IfModule> # ── Browser caching ─────────────────────────────────────────────────────────── <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" </IfModule> # ── Error pages ─────────────────────────────────────────────────────────────── ErrorDocument 404 /404.html
💾 Save
⬅ Back