javascript - 删除 index.php WAMP

标签 javascript php html .htaccess wamp

我有一个站点,它可以输入“www.mysite.com/folder/”(如果我在该文件夹中有一个索引文件)。

它也可以输入“www.mysite.com/folder/index.php”

一切都很好,但我想要它,所以如果你键入/index.php,如果我使用表单并发布到 index.php,它也会删除最后的 index.php 我不希望它显示在网址中。

我环顾四周,看到每个解决方案都说 .htaccess 重写,但它似乎不起作用/或者它与我想要的不一样?

还是我需要使用 javascript 并更新地址栏?

(我正在使用 WAMP)

编辑:

我尝试过的事情:

1

httpd.conf

AllowOverride All

2

我启用了: Apache 模块> rewrite_module

3

我已经在我的 wamp/www 文件夹中创建了一个 .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

4

wamp/apps/phpmyadmin/config.inc.php 添加了

$cfg['index_page'] = '';

编辑 2: 这看起来可行,但它弄乱了我对 index.php 的 POST,因此它破坏了我的登录(它不启动 session )

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]

最佳答案

.htaccess 文件绝对是正确的解决方案。如果它不起作用,请尝试以下可能的答案之一:

.htaccess not working on localhost with XAMPP

How to use .htaccess in WAMP Server?

.htaccess not working on WAMP


更新:重新阅读您的问题,you might be using an older htaccess script (对于 PHP < 5.2.6 版本)。我不确定该脚本是否适用于当前版本。尝试:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

?在最后一行的 index.php 之后是不同的

如果以上没有帮助,PHP 命令 phpinfo() 报告的 PHP 版本是什么?

<?php
    phpinfo();
    die();

关于javascript - 删除 index.php WAMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37708325/

相关文章:

javascript - 基于出生日期年龄不使用 javascript 显示

php简单的xml过滤器属性

php - getJSON 与 jquery

php - 如何对具有相同值的数据求和?

javascript - 在 Jquery 的列表中删除没有元素的列表

javascript - 如何停止HTML5的audio标签播放的音频

javascript - 在 Bootstrap 中,为什么我禁用的按钮没有工具提示?

javascript - 将 Prop 传递给同一组件的所有实例

javascript - 在javascript中监听端口

javascript - Angular : sustaining data on html refresh