Rebaz Salih
Rebaz Salih

Reputation: 39

Why below .htaccess code not works correctly

Below code is to make my url look pretty

RewriteEngine on
RewriteRule "^info/(.*)$" "/detail.php?id=$1" [L,NC]

detail.php will retrieve data from database based on ID we send to it, but page will be display as it has no css and JS file it displays as below:

enter image description here

While it should be like this enter image description here

Upvotes: 1

Views: 25

Answers (1)

Saif Manwill
Saif Manwill

Reputation: 722

Try with this :

Options +FollowSymLinks -MultiViews -Indexes

DirectoryIndex index.php

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^info/(.*)$ detail.php?id=$1 [L]

And add before your CSS & JS links this: http://example.com/your_files.css

The problem is from your links! Just add domain before them, and everything will work :)

Or just add this to your <head> tag : (Specify a default URL and a default target for all links on a page)

<base href="http://example.com/">

See this, it's the solution to your problem :)

Upvotes: 1

Related Questions