Satish51
Satish51

Reputation: 119

how htaccess rewrite works

How the htaccesss code works and how they used to redirect the link why index.php is used??

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /XYZ/
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Upvotes: 0

Views: 224

Answers (1)

Rajendran Nadar
Rajendran Nadar

Reputation: 5438

RewriteEngine On # Enable the rewrite engine

RewriteBase /XYZ/ #The base url can also be called as root url

RewriteRule ^index.php$ - [L] #Content between ^ $ are rewritten [L] is a flag

RewriteCond %{REQUEST_FILENAME} !-f # Don't select files

RewriteCond %{REQUEST_FILENAME} !-d #Don't select directory

Check about flags in Apache docs https://httpd.apache.org/docs/current/rewrite/flags.html

Have more question ask in comment.

Side note Use this if you have multiple conditions

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f

Upvotes: 1

Related Questions