/    Sign up×
Community /Pin to ProfileBookmark

css and images are not working with URL Rewrite

MY images and CSS is not working when try to use url rewrite

I uploaded all file as attachment.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@zahidrafauthorMar 02.2009 — Here are files
Copy linkTweet thisAlerts:
@martswiteMar 02.2009 — Hey zahidraf.

Ive recently been learning how to use modrewrite and cam ea cross this problem in my own site. If you haven't already looked at the mod_rewrite forum then go here

Its easy to fix instead of using a relative path like this
css/style.css[/QUOTE]

use an absolute path to the location of the files you want
http://yourdomain.com/css/style.css[/QUOTE]
Copy linkTweet thisAlerts:
@ravipnmdJun 30.2015 — Here are files[/QUOTE]

use ../image in place of image in show.php
Copy linkTweet thisAlerts:
@daviddakaraiJul 01.2015 — Options +FollowSymLinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteRule ^detail/([0-9]+)/?$ detail.php?id=$1

It redirects http://localhost/detail/123 URL to http://localhost/detail.php?id=123. The page redirects successfully, but the problem is CSS, JS, and images are not loading,

CSS, js files are located under http://localhost/css/ and http://localhost/js/

One solution is to use absolute path (ex /CSS, or /js rather than just CSS/, /js but this does not seem a reliable solution since we've to change it on all files,

Any other solution based on .htaccess rules, which is independent of editing all PHP files and let us use "relative paths"
×

Success!

Help @zahidraf spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...