how to make phpmyadmin work with kohana site? (.htaccess) - php

today i was trying to upload phpmyadmin to one of the folders with kohana site, but it turned out that instead of phpmyadmin i get empty page. so i think that this is the problem of rewriting rules in .htaccess in the root directory of the site.
.htaccess file has the following lines:
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
my phpmyadmin index.php file is located in phpmyadmin/ directory, but, as i've understood, every request is redirected to index.php in the root directory. how to make phpmyadmin work not breaking routing of kohana?
thanx for help!

Just add another RewriteCond before the last RewriteRule:
RewriteCond %{REQUEST_URI} !^/phpmyadmin
or to be more explicit, you can add another rule before the existing RewriteConds:
RewriteCond %{REQUEST_URI} ^/phpmyadmin
RewriteRule ^.*$ - [NC,L]

Related

Redirect wordpress website to a directory using htaccess

I've a wordpress installation inside a directory "public_html/mywebsite/"
. My root directory is "public_html/". My domain wwww.mywebsite.com pointed to the root folder "public_html/". Due to some reasons, I can't point the domain to the "mywebsite" folder. But I want to load the website from the "public_html/mywebsite/" directory when wwww.mywebsite.com is called. I tried with htaccess for this implementation. But not working.
In the "public_html/" directory, I put a .htaccess file and added the following code;
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mywebsite.com$
RewriteRule ^(/)?$ mywebsite [L]
It redirects the website to the "mywebsite" folder but it returns 404 page of the wordpress website.
I modified the .htaccess of the wordpress directory like this;
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(mywebsite|mywebsite/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any idea to solve this?
I used the wordpress redirect rule based on the following link and this worked for me.
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
For more security .I made a new folder with a long random name and installed Wordpress there .To redirect visitors to that wordpress folder without them noticing anything in URL, I made a .htaccess file and wrote this in it.
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L]
</IfModule>
first part is for security, second part is redirect.I replaced "my_subdir" with the random folder, and replaced "example.com" with my website.

.htaccess RewriteRule 404 Not Found

I'm having issues with .htaccess RewriteRule. all I'm trying to do is
rewrite this url - www.example.com/public/?q=admin
to - www.example.com/public/admin
but now when I go to this url www.example.com/public/admin it says not found.
but this url is working ww.example.com/public/?q=admin
here is my .htaccess code
Options All -Indexes
<FilesMatch "(config|.+\.html)\.php">
deny from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(bmp|cgi|css|flv|gif|ico|jpe?g|js|png|swf|xml)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) ?q=$1&%1 [L,QSA]
</IfModule>
Does anyone know to help?
UPDATE
This script installed inside a subdomain and a sub folder
like this
http://subdomain.maindomain.com/comingsoon/
coming soon is the root folder
http://subdomain.maindomain.com/comingsoon/public is another folder where placed .htaccess file.
I'm using mini php framwork called Swiftlet
https://github.com/AliasIO/Swiftlet
You can use this rule in your .htaccess for your required url.
RewriteRule ^public/(.*)$ public?q=$1 [L,QSA]
UPDATE 1:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain.com
RewriteRule ^public/(.*)$ http://subdomain.domain.com/comingsoon/public?q=$1 [L,NC,QSA]
Ok, so after your update, try this :
RewriteBase /comingsoon/public
RewriteRule ^(.*)$ /?q=$1 [L,QSA]

Yii2: Hiding frontend/web and backend/web from UrlManger

I managed to hide frontend/web and backend/web/ using .htaccess file. But the urlManager unable to understand that. I'm trying to create url like site/index and it should be something like this: example.com/site/index but it creates example.com/frontend/web/site/index.
How do I solve this problem with UrlManager?
Update: .htaccess in root directory.
Options -Indexes
RewriteEngine on
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} admin
RewriteRule .* backend/web/index.php [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/
RewriteCond %{REQUEST_URI} !admin
RewriteRule .* frontend/web/index.php [L]
</IfModule>
and here is the one I used in both frontend/web and backend/web:
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . index.php
I use this .htaccess config and it works fine for me. You need only one .htaccess file in your site root directory, and set frontend / backend configuration as described. Maybe this will work for you too.

Rewrite rules for custom CMS

I'm in the process of building a custom CMS for a client and I'm getting stuck on rewrite rules in .htaccess. I'm trying to rewrite anything to page/?pid=xxx -- so, for example, /about becomes page/pid=123.
I assume the problem that I'm having is twofold: I'm building this site in a subdirectory for the time being (/clients/afsb) and I've also got an existing rewrite rule in place to remove the .php from file extensions. Another possible wrinkle is that I'd like to be able to have the rewrite rule ignore any files that actually exist -- for example, the home page is at index.php (or just /, in this case) and I wouldn't want the rule to affect that. Likewise I've got two other pages that are not dynamic (/contact, for example.) Here's what I've tried in .htaccess for the time being:
<Files php.ini>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /clients/afsb
# Redirect to remove .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# Redirect to "page" for dynamic pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ page?&pid=$1
<Files ~ "\.inc$">
Order allow,deny
Deny from all
</Files>
I'm obviously not too strong with .htaccess or regex in general so I'd appreciate any direction you can give. Thanks!
Figured it out, this is what I needed -- I was missing the caret. Thanks to both for looking into it.
# Redirect to remove .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# Redirect to "page" for dynamic pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page?pid=$1 [L]

Deny access to all files except one from subdirectory

I am trying to restrict access to all files in my home directory, then to allow only one main php file from a subdirectory using one .htaccess file, but it does not work as expected. It shows only "Forbidden" for every request. How to make it work as expected?
Now I am using :
order allow,deny
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$ [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /path_to_file/index.php [QSA]
You can just forward all requests to that particular file. Put this in your root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/subdir/file\.php$ [NC]
RewriteRule ^ /subdir/file.php [QSA]

Categories