Arama Yap Mesaj Gönder
Biz Sizi Arayalım
+90
X
X
X
X

Knowledge Base

Homepage Knowledge Base General .htaccess Rewrite Rule: Index.php R...

Bize Ulaşın

Konum Halkalı merkez mahallesi fatih cd ozgur apt no 46 , Küçükçekmece , İstanbul , 34303 , TR

.htaccess Rewrite Rule: Index.php Redirection and SEO

This .htaccess rule ensures that incoming requests are redirected through index.php on Apache servers if the mod_rewrite module is enabled. This structure is especially used in SEO-friendly (pretty URL) systems and PHP applications with an MVC structure.

Code Explanation:



RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]


Detailed Meaning:

  • : These rules work if mod_rewrite is installed. If it is not installed, it is ignored.

  • RewriteEngine On: Activates the URL rewriting engine.

  • RewriteCond %{REQUEST_FILENAME} !-d: Continues if the requested address is not a physical folder.

  • RewriteCond %{REQUEST_FILENAME} !-f: Continues if the requested address is not a physical file.

  • RewriteRule ^(.*)$ index.php [QSA,L]: Redirects all other requests to the index.php file.

Meaning of [QSA,L]:

  • QSA (Query String Append): Preserves the query parameters of the original URL.

  • L (Last): No other redirection rule will run after this rule.

Example:

http://siteadi.com/hakkimizda

If this request is not actually a physical file or folder, it is redirected to index.php. Redirection can be done on the PHP side with $_SERVER['REQUEST_URI'] or $_GET.

Usage Areas:

  • In PHP MVC Frameworks (Laravel, CodeIgniter, Slim)

  • In CMS infrastructures such as WordPress, Joomla

  • When setting up an SEO-friendly URL system

Requirements:

  • The mod_rewrite module must be active on the Apache server.

  • The use of .htaccess files must be allowed with AllowOverride All permission.

This structure is commonly used in dynamic web applications to simplify URL management and control redirects centrally through index.php.

 

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(1894 times viewed / 466 people found it helpful)

Call now to get more detailed information about our products and services.

Top