我安装了 XAMPP,我在 localhost/上运行所有内容 所以想象我有 localhost/website/index.php 或 www.website.com/index.php;
如何删除index.php和/或将其替换为类似的内容; localhost/website/:) 或 www.website.com/:)
或显示为; localhost/website 或 www.website.com
示例;
$URLcapture = $_SERVER['PHP_SELF'];
$URLcustom = ":)";
$_SERVER['PHP_SELF'] = $URLcustom;
echo $_SERVER['PHP_SELF'];
这当然显示了 :) 但我怎样才能在我的 URL 中获取 :) 呢?
谢谢你, F4LLCON
编辑
在加载的模块下我可以看到 mod_rewrite。
一切之前的步骤 - 开始 - 在 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]
也尝试过
RewriteEngine On
RewriteBase /
RewriteRule index.php nieuw.php
我做错了什么?
编辑 2
根本不碰.htaccess。 1.关闭xampp和apache。
- 编辑了 C:\xampp\apache\conf 中的 httpd.conf;
2a 从上述步骤开始;
一切之前的 2a 个步骤 - 开始 - 直到
一切之前的 2a 步骤 -- 结束 -
2b。添加在http.conf末尾;
<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
3a。网站将打开,但布局不存在。所以它不会加载 style.css
3b。 .css 位于;
3b。 C:\xampp\htdocs\spiderweb\Web-projects\Web-stage\Nieuwidw\includes
3c。图像位于;
3c。 C:\xampp\htdocs\spiderweb\Web-projects\Web-stage\Nieuwidw\includes\images
下一步
- 在首页,您可以在每个产品下方看到“更多”按钮,如果您按“更多”,您将被重定向到 link.php 中的产品页面,但每个产品在 URL 中都有自己的 ID;
4a。 http://localhost/link.php?id=126这样页面就出现了;由于 URL 不同而未找到
如何解决这些问题?
最佳答案
在 PHP 中:
header("Location: http://www.example.com/");
但最好的方法是使用 htaccess (就像 ManseUK 所说)
关于php - 更改 URL PHP jQuery 或 mod_rewrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8310225/