How to check if mod_rewrite is enabled on the server?

I am currently using hosting with a lightpeed server. Hosting says that mod_rewrite enabled, but I cannot get my script to work there. Whenever I try to access the url, it returns 404 - not found page.

I put the same codes on another server that works with Apache. He works there. So I think this is the .htaccess and mod_rewrite problem.

But hosting support still insists that their mod_rewrite is turned on, so I would like to know how I can check if it is really turned on or not.

I tried to check using phpinfo() but no luck, I can not find mod_rewrite there because they use lightspeed ?

Is there any way to check? Please help me. Thank.

FYI: my .htaccess code

 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] </IfModule> 

I tried it too

 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 the same result.

+69
php url-rewriting .htaccess mod-rewrite lightspeed
Sep 07 2018-11-17T00:
source share
12 answers
  • To check if the mod_rewrite module is enabled, create a new php file in the root folder of your WAMP server. Enter the following

    phpinfo();

  • Access the created file from your browser.

  • Ctrl F to open the search. Search for 'mod_rewrite'. If it is turned on, you see it as "Loaded Modules"

  • If not, open httpd.conf (Apache configuration file) and find the following line.

    #LoadModule rewrite_module modules/mod_rewrite.so

  • Remove the pound sign ('#') at the beginning and save this file.

  • Restart the Apache server.

  • Access the same php file in your browser.

  • Look for 'mod_rewrite' again. You should be able to find it now.

+73
Jun 05 '12 at 3:50
source share

If you are using a virtual host configuration file, make sure that the virtual host has an AllowOverride All directive somewhere like this:

 <VirtualHost *:80> ... <Directory ...> AllowOverride All </Directory> </VirtualHost> 
+33
Sep 13 '13 at 14:47
source share

from the command line enter

sudo a2enmod rewrite

if overwrite mode is already on, it will tell you about it!

+25
Jun 08 '16 at 5:16
source share

If apache_get_modules () is not recognized or there is no information about this module in phpinfo (); try testing mod rewrite by adding these lines to your .htaccess file:

 RewriteEngine On RewriteRule ^.*$ mod_rewrite.php 

And mod_rewrite.php:

 <?php echo "Mod_rewrite is activated!"; ?> 
+14
Oct 13 '14 at 9:06
source share
Console

:

 <VirtualHost *:80> ... <Directory ...> AllowOverride All </Directory> </VirtualHost> sudo a2enmod rewrite sudo service apache2 restart 
+10
Oct 11 '13 at 13:21
source share

If

 in_array('mod_rewrite', apache_get_modules()) 

returns true , then mod-rewrite is enabled.

+9
Dec 02 '13 at 17:53
source share

If this code is in your .htaccess file (without checking for 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] 

and you can visit any page on your site with an error of 500 servers. I think it is safe to say that mod rewrite is enabled.

+7
Sep 07 '11 at 17:05
source share

PHP perdefined apache_get_modules() returns a list of allowed modules. To check if mod_rewrite is mod_rewrite , you can run a script on your server:

 <?php print_r(apache_get_modules()); ?> 

If the above example does not work, you can check mod-rewrite using the .htaccess file.

Create an htaccess file in the root of the document and add the following rewriteRule:

 RewriteEngine on RewriteRule ^helloWorld/?$ /index.php [NC,L] 

Now go to http://example.com/HelloWorld , you will be internally redirected to the /index.php page of your site. Otherwise, if mod-rewrite is disabled, you will get 500 Internel server errors.

Hope this helps.

+6
Feb 25 '17 at 4:47
source share

You can use php function

  apache_get_modules 

and check for mod_rewrite

 <pre> <?php print_r(apache_get_modules()); ?> </pre> 

http://in2.php.net/apache_get_modules

+4
Jun 05 2018-12-12T00:
source share

If you are on a linux system, you can check all the enable modules for apache2 (in my case) in the following folder: / etc / apache2 / mods-available

 cd /etc/apache2/mods-available 

enter: ll -a
if you want to check the available modules for php (in this case php 7) the folder / etc / php / 7.0 / mods-available

 cd /etc/php/7.0/mods-available 

for input: ll -a

+3
Nov 16 '16 at 22:17
source share

This works on CentOS:

 $ sudo httpd -M |grep rewrite_module 

Should output rewrite_module (shared)

+3
Jan 29 '17 at 14:47
source share

just create a new page and add this code

  <?php if(!function_exists('apache_get_modules') ){ phpinfo(); exit; } $res = 'Module Unavailable'; if(in_array('mod_rewrite',apache_get_modules())) $res = 'Module Available'; ?> <html> <head> <title>A mod_rewrite availability check !</title></head> <body> <p><?php echo apache_get_version(),"</p><p>mod_rewrite $res"; ?></p> </body> </html> 

and start this page, then find out whether the module can find out whether the module is available or not, if not, then you can request your hosting or enable it on the local computer, and then check this step of the walkthrough related to enabling the rewrite module in wamp apache https://youtu.be/xIspOX9FuVU?t=1m43s Wamp server icon β†’ Apache β†’ Apache modules and check the option to overwrite the module

+2
Oct 11 '16 at 7:23
source share



All Articles