使用.htaccess删除文件URL

时间:2015-11-06 03:41:28

标签: php .htaccess

我正在编写程序并使用xampp在本地运行它。该计划的完整路径是http://192.168.101.103:7777/WeltesMaft/index.php

我在C:\ xampp \ htdocs \ WeltesMaft \中写一个.htaccess 包含这个

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  ^/([^/]+)$
RewriteRule .*  http://192.168.101.103:7777/WeltesMaft/%1 [L]

但不知怎的,我的htaccess不起作用。它仍然显示像这样

http://192.168.101.103:7777/WeltesMart/_resources/main.php

在index.php中我包括main.php。因此,当用户输入index.php时,它会立即重定向到main.php。

我想隐藏它,以便网址看起来像这样,

http://192.168.101.103:7777/WeltesMart/

请帮助我在这里做错了什么......

2 个答案:

答案 0 :(得分:1)

您也可以使用此代码.....

<IfModule mod_rewrite.c>   
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ _resources/main.php/$1 [L,QSA]
</IfModule>

答案 1 :(得分:1)

RewriteBase更改为您的目录名称,然后按如下所示更改htaccess规则,然后重试:

RewriteEngine On
RewriteBase /WeltesMaft
RewriteCond %{REQUEST_URI}  ^/([^/]+)$
RewriteRule / index.php [L]