.htaccess 如何创建两个不同页面的漂亮url
我在同一目录中有两个页面,如下所示:.htaccess 如何创建两个不同页面的漂亮url,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我在同一目录中有两个页面,如下所示: www.example.com/index.php?page=about www.example.com/page.php?var=abc 我希望它像: www.example.com/about www.example.com/var/abc 这可能就是你要找的 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENA
www.example.com/index.php?page=about
www.example.com/page.php?var=abc
我希望它像:
www.example.com/about
www.example.com/var/abc
这可能就是你要找的
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^var/([^/]+) page.php?var=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+) index.php?page=$1 [L]
谢谢你的帮助。但是,当我使用www.example.com/var/abc时,所有css和js的URL都以www.example.com/var/为准。我如何解决这个问题?请在路径前面添加一个
/
。如href=“/path/to/style.css”
或使用完整路径<代码>href=”http://yoursite.com/path/to/style.css“在进行重写时,最好使用绝对路径,以防止发生这种情况。