Sunday, December 30, 2018

mod rewrite - apache mod_rewrite is not working or not enabled



I have installed rewrite_module and modified php.ini on Apache.



I create rewrite.php and .htaccess files, but it's not working.






/var/www/html
/var/www/html/test
/var/www/html/test/.htaccess
/var/www/html/test/rewrite.php




$ cat /var/www/html/test/.htaccess 


RewriteEngine On
RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]




$ cat /var/www/html/test/rewrite.php 




// mod_rewrite Test Page
// Copyright 2006 Webune.com
if($_GET['link']==1){echo"You are not using mod_rewrite";}
elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";}
else{echo"Linux Apache mod_rewrte Test Tutorial";}
?>






How To Test mod_rewrite in Apache Linux Server


by Webune


LINK1 = rewrite.php?link=1


LINK2 = link2.html


How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file


<< Go back to webune forums.









$ ls -l mod_rewrite.so
-rwxr-xr-x 1 root root 59256 Sep 20 23:34 mod_rewrite.so





$ cat /etc/httpd/conf/httpd.conf | grep mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so




$ cat /etc/httpd/conf/httpd.conf

Options Indexes FollowSymLinks


AllowOverride None

Order allow,deny
Allow from all


Answer



Try setting: "AllowOverride All".


No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...