2
我已經按照關於如何使用Mod_Rewrite
的一些教程,但沒有解決。在XAMPP中使用Mod-Rewrite
我有一個PHP索引頁,需要一個頁面參數,像這樣:
call: index?page=name1, name2, name3 etc.
<?php
if (isset($_GET['page']))
{
switch($_GET['page'])
{
case 'front':
include "front.php";
break;
default:
break;
}
}
>
我想運行國防部重寫,這樣的網址顯示爲site.com/name1
?這可能與我在上面使用的代碼?
下面是我一直在嘗試在Apache配置文件無濟於事。
阿帕奇/ CONF /的http.conf
line 122: LoadModule rewrite_module modules/mod_rewrite.so
line 188: DocumentRoot "G:/xampp/htdocs"
line 198: #default
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
line 215: <Directory "G:/xampp/htdocs">
line 228: Options Indexes FollowSymLinks Includes ExecCGI
line 235: AllowOverride All
# cgi
line 355:
<Directory "G:/xampp/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
G:\ XAMPP \阿帕奇\ CONF \額外\ http.v-hosts.conf
<VirtualHost *:80>
DocumentRoot G:/xampp/htdocs/
ServerName localhost
ServerAdmin [email protected]
<Directory "G:/xampp/htdocs/localhost/">
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot G:/xampp/htdocs/site2/
ServerName site2.localhost
ServerAdmin [email protected]
<Directory "G:/xampp/htdocs/site2.localhost/">
Options Indexes FollowSymLinks
AllowOverride FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
htaccess的文件
IndexIgnore *
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L]
So Gumbo如果您輸入site.com/foobar或將其鏈接到url,mod_rewrite會在內部調用/index.php?page=foobar,而site.com/foobar是您在url中看到的所有內容?任何關於如何實現我的原始目標沒有mod_rewrite的建議呢?也許通過PHP? – rrrfusco 2010-05-05 01:43:30
@rrrfusco;那麼,只需鏈接到'/ foobar'而不是'/index.php?page=foobar'。 – Gumbo 2010-05-05 02:05:07