我已经安装了XAMPP,我在我的localhost/上运行所有内容假设我有localhost/website/index。php或www.website.com/index.php;
如何删除index.php和/或将其替换为;Localhost/website/:)或www.website.com/:)
或显示为;本地主机/网站或www.website.com
例子;
$URLcapture = $_SERVER['PHP_SELF'];
$URLcustom = ":)";
$_SERVER['PHP_SELF'] = $URLcustom;
echo $_SERVER['PHP_SELF'];
这显示:)当然,但我怎么能得到:)在我的URL?
谢谢你,F4LLCON
编辑
在加载模块下,我可以看到mod_rewrite。
步骤- START -在httpd.conf中,我删除了;
# from infront of LoadModule rewrite_module modules/mod_rewrite.
改变;
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
和
<Directory "C:/xampp/cgi-bin">
AllowOverride All
Options +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
在。htaccess中我添加了
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
和also tried
RewriteEngine On
RewriteBase /
RewriteRule index.php nieuw.php
我做错了什么?
编辑2
不碰。htaccess。1. 关闭xampp和apache.
- 编辑httpd.conf在C:xamppapacheconf;
从以上步骤开始;
在一切之前的2个步骤——START - till
每一步之前的步骤——END -
2 b。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/home$ /spiderweb/Web-projects/Web-stage/Nieuwidw/index.php
RewriteRule ^/link$ /spiderweb/Web-projects/Web-stage/Nieuwidw/link.php
RewriteRule ^/contact$ /spiderweb/Web-projects/Web-stage/Nieuwidw/contact.html
RewriteRule ^/about$ /spiderweb/Web-projects/Web-stage/Nieuwidw/about.html
</IfModule>
- 启动xampp/apache并输入localhost/home
3。网站将打开,但布局不在那里。所以它不会加载style。css
3 b。C: xampp 根蜘蛛网 web项目 Web-stage Nieuwidw 包括
3 c。图片在;
3 c。C: xampp 根蜘蛛网 web项目 Web-stage Nieuwidw 图片包括
接下来- 在首页,你可以看到每个产品下的"more"按钮,如果你点击more,你将被重定向到link.php中的产品页面,但每个产品在URL中都有自己的ID;
4 a。http://localhost/link.php?id=126页面出现了;没有找到,因为URL不同
如何解决这些问题?
In php:
header("Location: http://www.example.com/");
但最好的方法是使用htaccess(如ManseUK所说)
如果你能够做到这一点,最好的方法是使用mod_rewrite -然后你包括一个规则,像下面的一个和index.php隐藏
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]