Hi, I decided to try some clean url (mod_rewrite) in my project. The clean url works but the CSS and images could not be found.
e.g: From index.php?id=home&idPage=1 to /home/1 . My CSS was redirect to /home/css/styles.css and not css/styles.css
Is there any way to fix that?
| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Css Not Working (Clean Url)
Started by RyosukeGunma, Jan 27 2011 01:15 AM
6 replies to this topic
#2
Posted 27 January 2011 - 08:18 AM
RyosukeGunma, on 27 January 2011 - 01:15 AM, said:
Hi, I decided to try some clean url (mod_rewrite) in my project. The clean url works but the CSS and images could not be found.
e.g: From index.php?id=home&idPage=1 to /home/1 . My CSS was redirect to /home/css/styles.css and not css/styles.css
Is there any way to fix that?
e.g: From index.php?id=home&idPage=1 to /home/1 . My CSS was redirect to /home/css/styles.css and not css/styles.css
Is there any way to fix that?
hi,
i did a quick search on google and came up with this. mod_rewrite should ignore some directories (like images and css directories). so try this code and post here to know if it worked for you
RewriteCond %{REQUEST_URI} ^/(cgi-bin|css|images)/?.
or try this one
RewriteRule ^(|css|images|) - [L]
hope you luck.
#3
Posted 30 January 2011 - 07:33 PM
Same happen to me once, and it was like a glitch the only solution I could find was to reinstall (I believe you are talking about Joomla!), the latest version and it worked.
And it also happened to me, that when I put different languages, the css would also stop working.
And it also happened to me, that when I put different languages, the css would also stop working.
#4
Posted 03 February 2011 - 07:39 AM
The best way and fastest method to solve it is to append / on the CSS path. A mod_rewrite rule when properly written will ignore existing files and directories while HTML css will be search on the rewritten URL.
Example: A mod rewritten URL like this
Will have its CSS search at
Appending a / on the CSS path like this
or even putting the full URL like this
Since you are doing some mod_rewrite and .htaccess modification, maybe this article can add some help in the future Essential .htaccess Commands, if the link is useful to you, I will appreciate dropping a comment.
Example: A mod rewritten URL like this
http://mynewserver.com/mycategory/myatriclename
Will have its CSS search at
http://mynewserver.com/mycategory/myatriclename/cssfilename.css
Appending a / on the CSS path like this
<link rel="stylesheet" href="/comments.css" type="text/css" media="screen" />
or even putting the full URL like this
<link rel="stylesheet" href="http://mynewserver.com/comments.css" type="text/css" media="screen" />always fixes the problem. For CSS images, do take note that they are being read relative to the stylesheet folder.
Since you are doing some mod_rewrite and .htaccess modification, maybe this article can add some help in the future Essential .htaccess Commands, if the link is useful to you, I will appreciate dropping a comment.
#5
Posted 07 February 2011 - 08:38 AM
Another way to do it, even though it usually is a less smooth way is to make one string.
The rewrite rule could look something like this:
and you would have nice clean URL, but in PHP you could access the string through $_GET['mygetkey']; which would have all the line, for example 'home/category/article/id' but in this case you would need to get your parameters yourself, usually I just create a navigation class which makes everything simple on later usage.
Mod rewrite is really powerful, there are plenty ways to do things, just you need to find the solution you need.
The rewrite rule could look something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?mygetkey=$1 [QSA,L]
</IfModule>
and you would have nice clean URL, but in PHP you could access the string through $_GET['mygetkey']; which would have all the line, for example 'home/category/article/id' but in this case you would need to get your parameters yourself, usually I just create a navigation class which makes everything simple on later usage.
Mod rewrite is really powerful, there are plenty ways to do things, just you need to find the solution you need.
#6
Posted 24 February 2011 - 02:30 AM
Thanks everyone. I have tried RewriteRule ^(|css|images|) - [L] and it didn't work. I managed to get the CSS working by putting a slash / on every src, which is a bit long but still worth it.
Does anyone know if it's possible for mod rewrite to get access a MySQL table and get data? I was thinking to put a custom fieldname in a MySQL table so we could put our own clean URL. A lot of CMS like Joomla can put their own custom URL.
Does anyone know if it's possible for mod rewrite to get access a MySQL table and get data? I was thinking to put a custom fieldname in a MySQL table so we could put our own clean URL. A lot of CMS like Joomla can put their own custom URL.
#7
Posted 04 July 2011 - 05:54 AM
I have experienced this issue yesterday.
With clean-urls enabled I have discovered that if any drupal webpage has more than one arg in the url, then images linked relative to the site don't appear.When clean-urls are disabled, the images work on every pages. If you get any ideas, please share with us.
With clean-urls enabled I have discovered that if any drupal webpage has more than one arg in the url, then images linked relative to the site don't appear.When clean-urls are disabled, the images work on every pages. If you get any ideas, please share with us.
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users














