Url friendly without losing styles css / js / images

470 views Asked by At

I have a website too extensive editing the URLs of styles css and files js, images would cost me too much time.

I'm working at localhost

localhost/project/index.php

The friendly url I want to have:

localhost/project/index/

From this url

localhost/project/online.php

to this

localhost/project/online/video/hd/free/

I have observed this website http://crazycafe.net/demos/seo/ and its source code, the styles css is maintained this way: <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"> without adding an absolute URL to styles css and their files and images.

How do i create a friendly url this way?

If the user modifies the url in this way:

http://crazycafe.net/demos/seo

Redirect to this way:

http://crazycafe.net/demos/seo/

On the other hand like conserving the styles css the files js and images, without having to modify to an absolute route.

My file directory is:

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

Note:

I found this question in SO, of how conserve CSS styles.

But I do not understand the use of friendly URL - .httaccess

1

There are 1 answers

3
Lajos Arpad On BEST ANSWER

You need to switch on mod_rewrite and use it. Example:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/ [R=301,L]

Folder-based example:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1/(.*)$ http://gs.mt-example.com/folder2/$1 [R=301,L]

Your case:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^online.php$ project/online/video/hd/free/$1 [R=301,L]

See more here.