我有一个网站过于广泛地编辑样式css
和文件js
的网址,images
会花费我太多时间。
我在localhost工作
localhost/project/index.php
我想要的友好网址:
localhost/project/index/
来自此网址
localhost/project/online.php
到这个
localhost/project/online/video/hd/free/
我观察了这个网站http://crazycafe.net/demos/seo/及其源代码,样式css
以这种方式维护:<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
没有为样式css
及其文件和images
添加绝对网址。
如何以这种方式创建友好的网址?
如果用户以这种方式修改了网址:
http://crazycafe.net/demos/seo
重定向到这种方式:
http://crazycafe.net/demos/seo/
另一方面,保存样式css
文件js
和images
,而不必修改为绝对路径。
我的文件目录是:
assets/css/style.css
assets/js/app.js
assets/fonts/icons/image.png
assets/fonts/ttf/roboto.ttf
assets/img/system/image.png
assets/img/logo.png
注意:
我在SO中找到了这个question,关于如何保存CSS样式。
但我不明白友好网址的使用 - .httaccess
答案 0 :(得分:0)
您需要打开 mod_rewrite 并使用它。例如:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/ [R=301,L]
基于文件夹的示例:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1/(.*)$ http://gs.mt-example.com/folder2/$1 [R=301,L]
你的案子:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online.php$ project/online/video/hd/free/$1 [R=301,L]
查看更多here。