joonasp
By:
joonasp

URI redirect - mod_rewrite problem.

April 6, 2015 896 views
LAMP Stack Apache

Hello, I recently started using mod_rewrite but so far I have had tough luck on getting it working.

I have tested that my .htaccess is being read by putting garbage there. Also when the garbage is in <IfModule mod_rewrite>. phpinfo() says, that mod_rewrite is enabled.

My addresses look like the following index.php?address=page

# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /

DirectoryIndex index.php

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/css
RewriteCond %{REQUEST_URI} !^/html
RewriteCond %{REQUEST_URI} !^/images
RewriteCond %{REQUEST_URI} !^/js
RewriteCond %{REQUEST_URI} !^/php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?address=$1 [L]
</IfModule> 

RedirectMatch ^/css(/?)$ /
RedirectMatch ^/html(/?)$ /
RedirectMatch ^/images(/?)$ /
RedirectMatch ^/js(/?)$ /
RedirectMatch ^/php(/?)$ /
1 comment
  • What is occurring when you attempt to use this configuration? I would normally ask if you enabled mod_rewrite by running a2enmod rewrite but it sounds like you've got that covered. Is anything being recorded in your Apache logs when you attempt to access a URL that uses this rewrite?

Be the first one to answer this question.