Pavel Kocfelda Pavel Kocfelda - 3 months ago 19
Apache Configuration Question

WAMP nice URL's redirect to direct file

Hello when I trying nice url with htaccess it's redirecting to file, so when I type www.page.com/mainpage it's redirect to www.page.com/mainpage.php and not to www.page.com/index.php?arg1=mainpage

my .htaccess looks like

RewriteEngine On
RewriteBase /
Options +FollowSymlinks


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ ?arg1=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^([^/]+)/([^/]+)?/?$ ?arg1=$1&arg2=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)?/?$ ?arg1=$1&arg2=$2&arg3=$3 [L,QSA]

Answer

You probably have the MultiViews enabled. Also, your rewrites are not referencing index.php anywhere. Try the following:

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?arg1=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^([^/]+)/([^/]+)?/?$ index.php?arg1=$1&arg2=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)?/?$ index.php?arg1=$1&arg2=$2&arg3=$3 [L,QSA]