删除“index.php?page=文件名”
我希望我的网站看起来像这样: http://www.example.com/about 而不是 web_url/index[dot]php?page=关于
在我的index[dot]php里面,我的导航链接是这样的:
<a href="index[dot]php?page=about">about</a>
etc.
...
$view = $_GET['page'];
switch($view){
case 'about':
include("pages/about.html");
break;
case 'project':
include("pages/project.html");
break;
... and so on
}
/* I have tried edit .htaccess file */
like this:
order allow,deny
allow from all
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ websiteurl/$1 [R=301,L]
请帮忙!
谢谢, 别名
I would like my site looks like this:
http://www.example.com/about instead of web_url/index[dot]php?page=about
Inside my index[dot]php, my navigation links like this:
<a href="index[dot]php?page=about">about</a>
etc.
...
$view = $_GET['page'];
switch($view){
case 'about':
include("pages/about.html");
break;
case 'project':
include("pages/project.html");
break;
... and so on
}
/* I have tried edit .htaccess file */
like this:
order allow,deny
allow from all
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ websiteurl/$1 [R=301,L]
Please help!
Thanks,
Alias
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我所做的:
然后我有一个文件 run.php,它可以根据全局变量计算文件路径:
然后您可以将其包含在内,将其作为模板读取,无论您做什么。
Here's what I do:
then I have a file run.php that calculates the file paths from the globals:
Then you can include that, read it as a template, whatever you do.
试试这个:
$_SERVER[REQUEST_URI] 将获取 http 主机 url 之后的 URI 段,因此
try this:
$_SERVER[REQUEST_URI] will get the URI segment after the http host url, hence