我正在尝试.php
从我网站上的文档中删除文件扩展名,因此 URL 会像这样:
http
://www.mysite.com/home/
而不是这样:
http ://www.mysite.com/主页.php
我已经尝试了各种 mod_rewrite 代码,除了这个之外,没有一个对我有用:
#Enable rewrite engine
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://www.mysite.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://www.mysite.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
我对此一无所知.htaccess
,而且我是 php 新手,所以我基本上无法弄清楚这一点。目前这是隐藏的,.php
但它以原始格式/文本喷出页面 php 内容,而不是像这样执行:
<?php
$page_title = "Home";
include('includes/header.php');
include('includes/mod_home/mod_intro.php');
include('includes/copyrightbar.php');
include ('includes/mod_login/login_form.php');
include('includes/mod_home/mod_welcome.php');
include('includes/mod_home/mod_platinum.php');
?>
<?php include('includes/mod_home/mod_starlight.php'); ?>
<?php include('includes/mod_home/mod_diamond.php'); ?>
<?php include('includes/mod_home/mod_newest.php'); ?>
<?php include('includes/mod_home/mod_featured.php'); ?>
<?php include('includes/mod_home/mod_gold.php'); ?>
<?php include('includes/footer.php'); ?>
为什么会这样?我已经遵循了所有在线教程,其他所有人似乎都没有这样的问题。我的服务器确实支持.htaccess
并且正在运行 Linux。
例如,我的链接仍然指向home.php
(我需要更改这些吗?)