
MAKE REWRITE RULES ON .HTACCESS FILE
If you need to make a rewrite rule on your .htaccess file, for example a condition if a URL not contains an string, you will need to make the following:
- Before we begin generating the actual URL rewrites, we need to activate the apache mod_rewrite module that controls them. Lets type in your terminal:
1sudo a2enmod rewrite - Edit (or create) an .htaccess file on your project root:
1sudo nano /var/www/site.com/.htaccess - Those are some examples of what you can get done with your .htaccess file:
123456789101112131415<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-f# redirect all from ^find-your-prod.aspx to find-your-prod.phpRewriteRule ^find-your-prod.aspx find-your-prod.php [QSA,L]# redirect all from find-your-prod.php to find-your-prod (remove .php)RewriteRule ^find-your-prod.php(.*)$ /find-your-prod$1 [L,R=302]# If url not contains string (CONDITION IS TRUE) then, redirect# => if url not contains /catalog/seo_sitemap/category redirect to /html-catalogRewriteCond %{REQUEST_URI} !^/catalog/seo_sitemap/category(/|$)RewriteRule ^catalog(.*)$ /html-catalog$1 [L,R=302]</IfModule>