Fan Fan - 5 months ago 23x
PHP Question

php short url weird appearance

There are few question to ask,hope that can be clipping solved .
I want to make a short URL for my web and setting

file to achieve it.

Here is the original URL:

Here is the URL I want to make short:

Here is the
code :

AddHandler application/x-httpd-php70 .php

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^Herald$ view/FACI_herald_E1.view.php [NC,L]
RewriteRule ^Herald/$ view/FACI_herald_E1.view.php [NC,L]

And it work! But weird things appeared, such as css, jquery ,image ,all of
web control will be failed to work. I can't figure out the problem of the setting.

Please help me find the issue, Thanks for your help!


The path of your CSS, JS & IMAGES changes because of rewrite rule. Please add / at start of every CSS, JS & IMAGES.

What is cause?

Look at end of your URL It look there is folder at your root directory with name Herald. So it search for CSS, JS & IMAGES inside folder Herald.

Solution If you add / at start of your CSS, JS & IMAGES path. It search for CSS, JS & IMAGES inside root directory.

For example:

Change From

    <link rel="stylesheet" href="include/bootstrap-3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="include/bootstrap-3.3.6/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="include/css/faci.css">
    <script src="include/script/jquery-1.12.3.min.js"></script>
    <script src="include/bootstrap-3.3.6/js/bootstrap.min.js"></script>

    <img id="real_image" src="include/img/img_default.jpg">
    <img src="include/img/ajax-loader.gif">


    <link rel="stylesheet" href="/include/bootstrap-3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="/include/bootstrap-3.3.6/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/include/css/faci.css">
    <script src="/include/script/jquery-1.12.3.min.js"></script>
    <script src="/include/bootstrap-3.3.6/js/bootstrap.min.js"></script>

    <img id="real_image" src="/include/img/img_default.jpg">
    <img src="/include/img/ajax-loader.gif">