Anarchia_92
01-07-2013, 15:38
Salve a tutti,
sto facendo un file .htaccess per il classo URL Rewriting solo che mi succede una cosa strana.
Allora io ho due tipi di URL:
localhost/index.php?action=news
localhost/index.php?action=news&view=1
Ho scritto il seguente codice nel file .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} index\.php
RewriteCond %{QUERY_STRING} ^action=([a-z]+)$
RewriteRule ^index\.php$ /%1? [R=301,L]
RewriteRule ^([a-z]+)$ index.php?action=$0 [L]
RewriteCond %{QUERY_STRING} ^action=([a-z]+)&view=([0-9]+)$
RewriteRule ^index\.php$ /%1/%2? [R=301,L]
RewriteRule ^([a-z]+)/([0-9]+)$ index.php?action=$0&view=$1 [L]
Per quanto riguarda la prima URL funziona mentre la seconda no..
Allora se io digito:
localhost/index.php?action=news FUNZIONA!
localhost/news FUNZIONA!
localhost/index.php?action=news&view=1 FUNZIONA
localhost/news/1 NON FUNZIONA
Come posso risolvere questa cosa?
EDIT: mi sono accorto che localhost/news/1 mi prende come unico GET news/1 e quindi non riesco ad andare nel database a prendere la news 1.
Infatti risulta index.php?action=news/1 invece di index.php?action=news&view=1 come potrei risolvere?
Grazie in anticipo.
Saluti Andrea.
sto facendo un file .htaccess per il classo URL Rewriting solo che mi succede una cosa strana.
Allora io ho due tipi di URL:
localhost/index.php?action=news
localhost/index.php?action=news&view=1
Ho scritto il seguente codice nel file .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} index\.php
RewriteCond %{QUERY_STRING} ^action=([a-z]+)$
RewriteRule ^index\.php$ /%1? [R=301,L]
RewriteRule ^([a-z]+)$ index.php?action=$0 [L]
RewriteCond %{QUERY_STRING} ^action=([a-z]+)&view=([0-9]+)$
RewriteRule ^index\.php$ /%1/%2? [R=301,L]
RewriteRule ^([a-z]+)/([0-9]+)$ index.php?action=$0&view=$1 [L]
Per quanto riguarda la prima URL funziona mentre la seconda no..
Allora se io digito:
localhost/index.php?action=news FUNZIONA!
localhost/news FUNZIONA!
localhost/index.php?action=news&view=1 FUNZIONA
localhost/news/1 NON FUNZIONA
Come posso risolvere questa cosa?
EDIT: mi sono accorto che localhost/news/1 mi prende come unico GET news/1 e quindi non riesco ad andare nel database a prendere la news 1.
Infatti risulta index.php?action=news/1 invece di index.php?action=news&view=1 come potrei risolvere?
Grazie in anticipo.
Saluti Andrea.