Question

I don't know if title is correctly placed.

I am using .htaccess trying to write readable urls. I am using following configuration. You can get fill .htaccess in the link provided.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

I have created simplest scenario. Here is a zipped file for the code (Sorry if I am not allowed to put personal site here.)

If you download the zipped file, and extract and use it in local system and perform following action, you will get what I am trying to say.

assuming

localhost/htaccess

as the root of my provided code.

if you try localhost/htaccess/first

it executes as expected

if you add one "/" at the end as localhost/htaccess/first/

all the folder structure changes. You can see the changes too.

At first case, it assumes

localhost/htaccss

as root, and loads other files (css, images) from there.

In second case, it assumes

localhost/htaccess/first/

as root and loads other files after first/. But expected location was htaccess/

I could not explain this in word, so I provided example url with sample case scenario.

Était-ce utile?

La solution

Edit header.php so your stylesheet is relative to the root rather than the path so it can be found regardless of the ending slash:

<link type="text/css" rel="stylesheet" href="/htaccess/assets/css/style.css" />

Alternatively, you could point the base path to where you need it pointed:

<base href="http://localhost/htaccess/" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top