ç¶:åå¨ãããã¡ã¤ã«ã¯ã¹ã«ã¼ããã
mod_rewriteã®ã話ã
以åã«æ¸ããæåã®çåã解決ããã®ã§åæ²è¼ã
ãã¡ã¤ã«ãåå¨ããå ´åã¯ãã®ãã¡ã¤ã«ã表示ããåå¨ããªãå ´åã¯index.phpã表示ããããã«ãããã
ããããä¾ã以ä¸ã®ããã«ãªã£ã¦ããããå®éã«ã¯ãã¾ãåããªãã
RewriteEngine on RewriteBase / #ãã¡ã¤ã«ãåå¨ããªãä¸ã¤ããã£ã¬ã¯ããªãåå¨ããªãå ´åã¯ãindex.phpã表示 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^$ /index.php [L,QSA] RewriteRule ^(.*)$ /index.php?jb=$1 [L,QSA]
ä¸è¨ã®ä¾ããªããã¾ãåããªããã¨ããã¨ãRewriteCondã¯ç´ä¸ã®RewriteRuleã«ããéããªãã®ã§ãã
ã¤ã¾ããåå¨ãããã¡ã¤ã«ã«å¯¾ãã¦ã
RewriteRule ^(.*)$ /index.php?jb=$1 [L,QSA]
ã®ã«ã¼ã«ãé©å¿ããã¦ãã¾ããã¨ã«ãªãã¾ãã
ãããåé¿ããçºã®è§£æ±ºçã¯ä¸è¨ã®ä¾ã®éãã§ãã
解決ç1:RewriteRuleã®é çªãå¤ãã
ä¸è¨ã®ä¾ã§ã¯é çªãå¤ãããã¨ã§è§£æ±ºãã¾ãã
RewriteEngine on RewriteBase / RewriteRule ^$ /index.php [L,QSA] #ãã¡ã¤ã«ãåå¨ããªãä¸ã¤ããã£ã¬ã¯ããªãåå¨ããªãå ´åã¯ãindex.phpã表示 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?jb=$1 [L,QSA]
解決ç2:RewriteRuleæ¯ã«ãRewriteCondãæ¸ã
RewriteRuleæ¯ã«ãRewriteCondã1ã¤1ã¤æ¸ããã¨ã§åé¿ã§ãã¾ãã
RewriteEngine on RewriteBase / #^$ç¨ã®RewriteCondã¨RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^$ /index.php [L,QSA] #^(.*)$ç¨ã®RewriteCondã¨RewriteRule RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?jb=$1 [L,QSA]
解決3:åå¨ãããã¡ã¤ã«ã«å¯¾ãã¦RewriteRuleãå ã«é©å¿ãã
å
ã«åå¨ãããã¡ã¤ã«ã«å¯¾ãã¦ã«ã¼ã«ãé©å¿ãã¦ãã¾ãã
ãã£ã¡ã®æ¹ã楽ããããã¾ããã
RewriteEngine on RewriteBase / #ãã¡ã¤ã«ãåå¨ãããããã£ã¬ã¯ããªãåå¨ããå ´åã¯ããã®ãã¡ã¤ã«ã表示ãã RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.* - [L] #ãã¡ã¤ã«ãåå¨ããªãå ´åã«ä»¥ä¸ã®ã«ã¼ã«ãé©ç¨ RewriteRule ^$ /index.php [L,QSA] RewriteRule ^(.*)$ /index.php?jb=$1 [L,QSA]
解決ç4:ã«ã¼ã«ãè¯ãè¦ç´ãã
å®ã¯ã.*ã.+ã«å¤ããã ãã§ã1è¡ç®ã®ã«ã¼ã«ã¯å¿
è¦ãªãã£ãããã¾ãã
éä¸ã§æ°ãã¤ããã®ã§ããã説æãæ¸ããªããªãã®ã§æå¾ã«åãã¾ããã
RewriteEngine on RewriteBase / #ãã¡ã¤ã«ãåå¨ããªãä¸ã¤ããã£ã¬ã¯ããªãåå¨ããªãå ´åã¯ãindex.phpã表示 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /index.php?jb=$1 [L,QSA]
ãããªæãã§ãRewriteCondã¯ç´ä¸ã®RewriteRuleã«ã®ã¿é©ç¨ããã¾ãã
RewriteRuleãæ¸ãæã¯ãå¾ããè¦ã人ãåéãããªãããã«ä¸è¡ããã¦æ¸ãããã«ãã¾ãããã
é¢é£è¨äº
[Apache][mod_rewrite]存在するファイルはスルーしたい
The Definitive Guide to Apache mod_rewrite (Definitive Guides (Hardcover))
- ä½è : Rich Bowen
- åºç社/ã¡ã¼ã«ã¼: Apress
- çºå£²æ¥: 2006/02/22
- ã¡ãã£ã¢: ãã¼ãã«ãã¼
- ã¯ãªãã¯: 32å
- ãã®ååãå«ãããã° (3件) ãè¦ã
Apacheã¯ãã¯ãã㯠第2ç âWebãµã¼ã管çè ã®ããã®ã¬ã·ãé
- ä½è : Ken Coar,Rich Bowen,笹äºå´å¸
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã¸ã£ãã³
- çºå£²æ¥: 2008/09/26
- ã¡ãã£ã¢: 大åæ¬
- è³¼å ¥: 6人 ã¯ãªãã¯: 144å
- ãã®ååãå«ãããã° (32件) ãè¦ã