Hi i have such a problem in codeigniter. I cant use styles of my .css file. But I know that this filt is connected to my views. (Firebug). Here is my link for connecting:
`<link rel="stylesheet" href="images/Enlighten.css" type="text/css" />`
css file in directory /images/Enlighten.css
Here is my htaccess file:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|template|robots\.txt|public|)
RewriteCond %{REQUEST_URI} !\.(css¦js¦jpg¦gif)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
I think that my mistake is in this file.(I dont deal in this file :(( )
P.S Everywhere when i use styles from Enlighten.css text print as '??????????'
How about making it less complicated like this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
ps.
It's best not to place your CSS in the images directory to prevent confusion.
I always use an assets folder and organize everything in there:
/Assets
/css
/images
/js
use following code for your htaccess file :-
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I recommend to use the following .htaccess:
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Prevents user access to the application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Related
I looked at this: htaccess remove index.php from url but it didn't work and in the comments there seems to be disagreement on the top answer.
If I type in http://www.example.com/thanksgiving/index.php/getThankyou I get the page I want served.
If I type in http://www.example.com/thanksgiving/getThankyou I get a 404.
What I've tried in my htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/thanksgiving/(.*)/$ /thanksgiving/index.php/$1 [L]
</IfModule>
How do I do it so /thanksgiving/getThankyou/ or any url starting with /thanksgiving in the url leads to the proper resource being served? Again, it is currently available when index.php is in the url.
I also tried: RewriteRule ^/thanksgiving/[^/]*/$ /thanksgiving/index.php/$1 [L] but that didn't work either...
Edit: It seemed part of the htaccess is being set by wordpress and may be conflicting with the desired behavior above:
The wordpress part of the same htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Is this interfering? How do I reconcile this with the /thanksgiving/ urls which are not part of the Wordpress application?
Edit:
The above only pertains to the root (public_html) htaccess, below is the htaccess in /thanksgiving/ itself, please analyze for conflicts, thanks for all your help!
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Do not change this line.
# Change example.com to your domain name
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change your_app_name to the subfolder name
RewriteCond %{REQUEST_URI} !^/thanksgiving/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change your_app_name to the subfolder name
# Change example.com to your domain name
RewriteRule ^(.*)$ /thanksgiving/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ thanksgiving/index.php [L]
You need to remove the leading slash from your rewrite pattern :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:thanksgiving/)?(.*)$ /thanksgiving/index.php/$1 [L]
</IfModule>
Otherwise the rule will accept the uri starting with a double leding slash (ie : //thanksgiving/ ) .
My site ww.example.com runs WordPress in its root directory, meaning that any paths are redirected to the WordPress install to be evaluated. I also have an install of DokuWiki under www.example.com/path/to/wiki/, which similarly uses .htaccess to deliver wiki pages at paths like www.example.com/path/to/wiki/wikipage.
The file structure on the server stores all the non-WordPress content in a subdirectory called content, so the Dokuwiki install is actually located in content/path/to/wiki/.
Unfortunately, whilst www.example.com/path/to/wiki/ displays correctly, www.example.com/path/to/wiki/wikipage is clearly passed back to the top-level WordPress .htaccess and returns a 404 error.
What do I need in my .htaccess files to make this set-up work?
Example .htaccess files
Top-level WordPress .htaccess
# Rewrite to content directory
RewriteCond %{DOCUMENT_ROOT}/content/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.php -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.html -f
RewriteRule ^(.*)$ /content/$1 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
DokuWiki .htaccess
RewriteEngine on
RewriteBase /path/to/wiki
RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ doku.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) doku.php?id=$1 [QSA,L]
I would think that all you need to do is omit the path to wiki and content directories from your .htaccess file in the root and include the path in the first rewriterule.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/content/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.php -f [OR]
RewriteCond %{DOCUMENT_ROOT}/content/$1index.html -f
RewriteRule ^(path/to/wiki/.+/?)$ /content/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(path/to/wiki|content)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
How do I redirect any .css file to a page/controller on my server using .htaccess?
I currently have the following rule:
# Remove index.php from Codeigniter
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I now want any .css file to be redirected to e.g http://127.0.0.1/asset/css?file=stylesheet.css. I have tried the following but receive a 404.
RewriteRule .*\.(css)$ /asset/css?file=$0 [NC,L]
#Rule for css
RewriteRule ([^.]+)\.css$ asset/css?file=$1.css [NC,L]
#end of css rule
# Remove index.php from Codeigniter
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I'm hoping you guys can help me out. I want to rename my theme's CSS & JS path but I can't seem to figure it out.
For example:
I want to change:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/style.css
to
http://cdn.(domain-name).com/style.css
& from:
http://cdn.(domain-name).com/wp-content/themes/smart-mag/js/bunyad-theme.js
to
http://cdn.(domain-name).com/js/bunyad-theme.js
etc, etc.
Here is what I tried in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
</IfModule>
#END WordPress
That modified htaccess did nothing at all. What am I missing/doing wrong here?
You need to change the order of your rules. The wordpress rules route all requests to index.php, including your /style.css etc URLs. So you need to route those first.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(css|js|jpe?g|gif|png|bmp)$
RewriteCond %{REQUEST_URI} !^/themes/smart-mag/
RewriteRule ^(.*) /themes/smart-mag/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^wp-content/themes/smart-mag/screenshot\.png|readme\.html|license\.txt|wp-content/debug\.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
#END WordPress
I'm trying to route all folders and subfolders to my index document.
It is working, but not completely, when I go deeper into a subfolder, the index.shtml getting loaded but without any CSS.
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.shtml [L]
</ifModule>
domain.tld/folder-1/folder-2 (any deeper then folder-1 and the CSS is gone.)