.htaccess not working

design

#1

Hi. I have recently been switching over the site to use php, but have had some issues trying to rename urls with the .htaccess file. Nothing seems to have an affect. I have placed the file in the root folder of the website folder. I would like to change links such as this one:

http://polarischurch.com/?action=pictures

to

http://polarischurch.com/pictures

Here is my .htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.$ - [NC,L]
RewriteRule ^(.
)$ index.php?page=$1

Thank you


#2

Each RewriteCond needs to be on a separate line, e.g.

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

That being said, you can express this using a single rule by negating the conditions:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?action=$1

#3

Thank you. I tried that, but still had no results. I’ve never used an htaccess file before. Possibly there is something simple I haven’t tried?


#4

Oh, wait. Changed “page=$1” to “action=$1” in my example — try again now? It helps if you use the right parameter name. :slight_smile:


#5

Updated my code. Still no result.

[update]
Never mind. Just realized how this works. I thought going to the link http://polarischurch.com/?action=pictures would redirect to http://polarischurch.com/pictures when it is the reverse. Thanks for the help!