繁体   English   中英

URL重写我不想在URL中显示index.php

[英]URL Rewriting I don't want to show index.php in url

我正在运行我的PHP应用程序

http:// localhost:8085 /

我的目录结构是这样的:C:\\ wamp \\ www \\ website

我已将.htaccess文件放在网站文件夹中。

<IfModule mod_rewrite.c>
#Turn on the RewriteEngine
RewriteEngine On
RewriteBase /website/
#Rules
RewriteRule ^(.*)$ index.php
</IfModule>

每当我单击index.php时,它将带我到http:// localhost:8085 /主页,这是错误的,我想访问http:// localhost:8085 / website

请指导我

您需要在index.php之前添加您的website ,例如,

RewriteRule ^(.*)$ /website/index.php

已更新,请尝试完整的代码,

RewriteEngine On
RewriteBase /website/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /website/index.php [L] 

注意:您需要在您的网站中使用的每个链接中使用http://localhost:8085/website/作为基本URL,否则它将重定向到http://localhost:8085/

<a href="http://localhost:8085/website/index.php">Home page</a>

或者,请勿在任何href之前使用/ ,而应使用文件名,例如,

<a href="index.php">Home page</a>

如果您使用的是<a href="/index.php">Home page</a> ,它将重定向到URL http://localhost:8085/索引页。

您可以使虚拟主机直接访问它https://httpd.apache.org/docs/current/vhosts/name-based.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM