I am using this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . public/$1 [L]
</IfModule>
I have tried this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
None of them working properly. Any ideas?
Thank you
Related
I'm needing to merge both of these inside my .htaccess folder. If the top one runs, WordPress works properly but my forum does not. If the bottom one runs it's reversed. I've done some research and I found it's because I have multiple RewriteBases in the code. I'm needing some help getting them merged together though. Thank you.
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /forum/index.php [L]
</IfModule>
I think I figured it out. This is at least working for me.
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/api/.* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^forum/\.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/. /forum/index.php [L]
</IfModule>
the .htaccess code is
RewriteEngine off
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ^(.*) public/$1 [L]
</IfModule>
what is the issue?
I'm not so sure if this is what you want to do, but try with this:
RewriteEngine Off
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ public/$1 [L,QSA]
</IfModule>
My url is like this : http://31.220.56.75/mysystem/public/index.php/login
I want remove index.php, to be like this : http://31.220.56.75/mysystem/public/login
My .htaccess :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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>
I try some tutorial di google. but I don't find the solution
Update :
I try update .htaccess like this :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It's not working
Try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
default .htaccess in public folder should be working very fine. check: original .htaccess
Follow the below .htaccess file, hopefully this will work.
If your are facing the issue of $_GET variable also i.e If your both URL index.php and without index.php is working but $_GET variables found not working, then the below of .htaccess code will work for you.
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
This is my .htaccess file in sub-folder...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
I want mydomain.com/sub-folder/string to processed by index.php as mydomain.com/sub-folder/?id=string
But I am getting 404... not sure why. This is my root .htaccess
# 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
Keep your root .htaccess as:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(index\.php|sub-folder(/.*)?)$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
And keep this in /sub-folder/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-folder/
RewriteRule ^index\.php$ - [L,NC]
RewriteRule (.+) index.php?id=$1 [L,QSA]
</IfModule>
how can i redirect from server.ip/~bogo/api/* to server.ip/~bogo/api/public/*?
any help please
Here's htacces in api directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
my htacces in public directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
but i got 404 error??
Ok i solved it here's my solution
api directory htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /~bogo/api/
RewriteCond %{REQUEST_URI} !/public/
RewriteRule (.*) public/$1
</IfModule>
public directory htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~bogo/api/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
Apache will go through .htaccess until no rules match anymore. The problem you are most likely facing, is that the new url is being matched by the regex of the same rule. You have created an infinite loop. You can fix this by making sure the rule doesn't match if the url already has 'public' in it:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/public/
RewriteRule (.*) public/$1 [L]
</IfModule>