I am having some problems with mod rewrite. The server is Ubuntu 12.04, Apache2, Php 5.4.
I want an url like this:
www.website.com/<modelName>/<imageNumber>
And
www.website.com/<modelName>
To actually show:
www.website.com/showimage.php?model=<modelName>&image=<imageNumber>
And
www.website.com/model.php?model=<modelName>
I have put this in the .htaccess:
RewriteEngine On
RewriteRule ^([^/]+)/([0-9]+)/?$ showimage.php?model=$1&image=$2 [R,L,NC,QSA]
RewriteRule ^([^/]+)/?$ model.php?model=$1 [R,L,NC,QSA]
I have checked that mod_rewrite is loaded in apache. But the page just doesn't redirect.
EDIT: Just to clarify, the result is a 404 'the resource / does not exist on this server' and 'the resource // does not exist on this server'.
The strange thing is that I was playing around with it yesterday and tried to make a rule that included website.com/model/modelName and that seem to be in effect now and impossible to get rid of. I have tried to restart Apache ten times, clear browser caches and even install another browser that I didn't have before but the die-hard redirect from yesterday keeps going even in the new browser (FireFox).
Are the new redirect rules that I have written correct?
How do I put them in action?
Should I set chmod 777 on .htaccess?
Thanks a lot...
EDIT: here is some more information.
I only have one (default) site and the files (including .htaccess) are just sitting in /var/www
The file /etc/apache2/sites-available/default looks like this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
I haven't changed anything there except Directory / AllowOverride All
.htaccess looks like this:
RewriteEngine On
RewriteLog "/etc/apache2/logs/rewrite.log"
RewriteLogLevel 9
RewriteBase /
RewriteRule ^([^/]+)/([0-9]+)/?$ showimage.php?model=$1&image=$2 [R,L,NC,QSA]
RewriteRule ^([^/]+)/?$ model.php?model=$1 [R,L,NC,QSA]
And I have run service apache2 restart endless times.
This url works fine:
/showimage.php?model=Ai&image=12
This one doesn't:
/Ai/12
HELP!