Coder Perfect

How can I see if mod rewrite is enabled on my server?


At the moment, I’m using a lightspeed server for hosting. Although my hosting provider claims that mod rewrite is enabled, I am unable to get my script to work. When I try to access the URL, I get a 404 – page not found error.

I used the identical scripts on a different server that runs Apache. Over there, it’s operating fine. So I guess, it’s the .htaccess and mod_rewrite issue.

However, Hosting support continues to assert that their mod rewrite is enabled, therefore I’m curious as to how I can determine whether it is.

I tried using phpinfo() to see if mod rewrite was present, but it wasn’t. Is this because they use lightspeed?

Is there a way to find out? Please assist me. Thank you very much.

My.htaccess code is as follows:

Options -Indexes

<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

This is something I attempted as well.

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

But same result.

Asked by knightrider

Solution #1

Type the following command from the command prompt:

It will inform you if the rewrite mode is already enabled!

Answered by KawaiKx

Solution #2

Answered by Fadzly Othman

Solution #3

If you’re using a virtual hosts configuration file, make sure the virtual host you’re working with contains the directive AllowOverride All someplace in it, like this:

<VirtualHost *:80>
    <Directory "directory/of/your/.htaccess">
        AllowOverride All

Basically, this tells the server to process all.htaccess directives.

Answered by Jahmic

Solution #4

This is how it works on CentOS:

$ sudo httpd -M |grep rewrite_module

Should rewrite module be output? (shared)

Answered by radtek

Solution #5

If apache get modules() is not recognized, or phpinfo() returns no information about this module, try testing mod rewrite by adding the following lines to your.htaccess file:

RewriteEngine On
RewriteRule ^.*$ mod_rewrite.php

And mod_rewrite.php:

<?php echo "Mod_rewrite is activated!"; ?>

Answered by wappy

Post is based on