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.)
Related
I have site with 2 other sites in subfolders
https://example.com/
https://example.com/demo1
https://example.com/demo2
All 3 sites are actually wordpress installations.
The problem is: when I opened a page
https://example.com/demo1/testpage
I got redirected to
https://example.com/testpage
Contents of example.com/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I've tried to add one more RewriteCond before RewriteRule (one line at a time):
RewriteCond %{REQUEST_URI} !demo1
RewriteCond %{REQUEST_URI} !^/demo1/(.*)$
RewriteCond %{REQUEST_FILENAME} !demo1
RewriteCond %{REQUEST_FILENAME} !^/demo1/(.*)$
But none of this worked.
So how to make it work and avoid redirect?
It's very strange but solution was to resave site url in wordpress settings on /demo1/wp-admin/options-general.php
I'm not expert using .htaccess
I need to direct any request at our website abutair.net, to open first WordPress workplace, then hide sub- folders at URL, such as an example below:
https://abutair.net/about-us/
Instead:
https://abutair.net/innerPages/wordpress-4.7.4/wordpress/about-us/
I've wrote at .htaccess of website root folder, the following:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?abutair.net$
RewriteCond %{REQUEST_URI} !^/innerPages/wordpress-4.7.4/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /innerPages/wordpress-4.7.4/wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?abutair.net$
RewriteRule ^(/)?$ innerPages/wordpress-4.7.4/wordpress/index.php [L]
</IfModule>
and at .htaccess WordPress inner folder, the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /innerPages/wordpress-4.7.4/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /innerPages/wordpress-4.7.4/wordpress/index.php [L]
</IfModule>
# END WordPress
It direct successfully to WordPress pages, but the sub-folders show at URL.
Please advice me how can solve this issue?
Thanks in advance,
I've read a lot of threads on this topic, but I'm not very proficient at this stuff and nothing has worked for me.
I installed Wordpress in a sub directory and:
Changed the site address URL to the main domain in WordPress.
Then I copied the .htaccess and index.php to the root directory.
Then I changed the index.php file so that the require(‘wp/wp-blog-header.php’) pointed to the subdirectory.
Everything works, except the subdirectory shows in the URL, which I would like to hide.
The subdirectory I installed to is 'NA20H'. After changing the index.php file to point to it, this is what I have.
The .htaccess file in the Root directory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
And the .htaccess in the subdirectory reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /NA20H/index.php [L]
</IfModule>
What do I need to do in order to get 'NA20H' to stop showing in the URLs?
Thank you.
No need to copy index.php to root. Just follow these steps.
Put this in the .htaccess in the root.
RewriteEngine On
RewriteBase /
RewriteRule ^$ NA20H/ [L]
RewriteRule ^(.*)$ NA20H/$1 [L]
Put this in .htaccess in the NA20H folder
RewriteEngine On
RewriteBase /NA20H/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
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
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>