Php 如何创建干净的URL

Php 如何创建干净的URL,php,Php,我有一个像这样干净的url 在模板中,我已经创建了基本路径url(top\u script.php) $url=isset($\u服务器['HTTPS'])?'https://':'http://'; $url.=$\u服务器['SERVER\u NAME']。“:8081”; $url.=htmlspecialchars($_服务器['REQUEST_URI']); $themeurl=dirname(dirname($url))。“/”; $basepath=$themeurl; 检查你的

我有一个像这样干净的url

在模板中,我已经创建了基本路径url(top\u script.php

$url=isset($\u服务器['HTTPS'])?'https://':'http://';
$url.=$\u服务器['SERVER\u NAME']。“:8081”;
$url.=htmlspecialchars($_服务器['REQUEST_URI']);
$themeurl=dirname(dirname($url))。“/”;
$basepath=$themeurl;

检查你的.htaccess请发布你的HTML,因为这很可能是一个相对路径问题。例如,链接文件“css/style.css”会将“css/style.css”添加到您所在的任何目录中。因此,mysite.com/some/folder/index.html将生成一个指向mysite.com/some/folder/CSS/style.CSS的CSS链接-我想象将a/固定到路径的开头将修复它。链接“/css/style.css”将始终指向mysite.com/css/style.cssquick fix,复制
http://localhost:8081/olshop/css/style.css
http://localhost:8081/css/style.css
。。。但说真的,您可能希望了解您的文件路径works@JúlioJamil@Andrew then jquery,image too??检查你的.htaccess请发布你的HTML,因为这很可能是一个相对路径问题。例如,链接文件“css/style.css”会将“css/style.css”添加到您所在的任何目录中。因此,mysite.com/some/folder/index.html将生成一个指向mysite.com/some/folder/CSS/style.CSS的CSS链接-我想象将a/固定到路径的开头将修复它。链接“/css/style.css”将始终指向mysite.com/css/style.cssquick fix,复制
http://localhost:8081/olshop/css/style.css
http://localhost:8081/css/style.css
。。。但说真的,您可能希望了解您的文件路径works@JúlioJamil@Andrew then jquery,图片也是??
$url  = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
$url .= $_SERVER['SERVER_NAME'].":8081";
$url .= htmlspecialchars($_SERVER['REQUEST_URI']);
$themeurl = dirname(dirname($url))."/";
$basepath = $themeurl;
<link rel="stylesheet" href="<?php echo $basepath ?>css/style.css" type="text/css">