im using codeigniter 3.1.9 and XAMP. i try eevrything but is not working
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please try this
RewriteEngine on
RewriteBase /foldername/
# RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note : If you put ".htaccess" inside a folder, don't forget to add RewriteBase.
Related
HI have some trouble to find solution that will redirect my page from link:
http://example.org/100
to
https://example.org/index.php?id=100
This is my .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 [QSA,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}
It works correctly only when you use full page address with https (https://example.org/100)
I find solution on my problem:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 [QSA,L]
<If "%{HTTPS} == 'off'">
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
I find solution of my problem:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 [QSA,L]
<If "%{HTTPS} == 'off'">
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
I put inside the public_html/ .htaccess code (at the begining)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]
and https:// was forced with success.
But i put on the public_html/subdomain/ .htaccess code (at the begining)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
and the subdomain get's messy.
What is wrong about this code i put in the subdomain?
I can't do anything more. Some expertise is needed.
Thank you.
Create your new .htaccess file with the following code in your sub folder.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^demos.9lessons.info$ RewriteCond
%{REQUEST_URI} !^/demos/ RewriteRule (.*) /demos/$1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^labs.9lessons.info$ RewriteCond
%{REQUEST_URI} !^/labs/ RewriteRule (.*) /labs/$1
Im getting way confused about theese apache2 rewrites.
I need to make a REST interface where I use the real URL's of course.
Im testing at localhost atm.
http://localhost/ssase12/services/users/
http://localhost/ssase12/services/users
should be sent to the
http://localhost/index.php?rt=index/users
So I need to detect the 3. folder/name and redirect it to the link above - users = $1.
Makes sence?
Im trying to do this with a .htaccess placed in the users folder... can I maybe do this from the services folder? So everything written after
http://localhost/ssase12/services/blah(/)
would be sent as well?
Thanks
You can put the rules in either the document root
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ssase12/services/(.*?)/?$ /index.php?rt=index/$1 [L]
or the ssase12 directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^services/(.*?)/?$ /index.php?rt=index/$1 [L]
or the services directory.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)/?$ /index.php?rt=index/$1 [L]
is there any way to access e.g. prolink.php file in zend /public directory by typing mydomain.com/prolink.php, and go to application in other cases (index.php)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
should I specify a route for that?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^prolink.php$ public/prolink.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
If the request is for a file that exists already on the server, index.php isn't served.
put index.php file into the public folder
and put .htaccess in the root folder, witch contents
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Options -Indexes
I have zend framework htaccess now:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]
But I don't know how to redirect all "link" parameters like js, css, img.
Solution one:
Your web server should point to public/ directory, not to root directory of ZF project.
Solution two (better one I think):
Your web server points to ZF project directory, or even ZF project is in sub directory.
Like http://localhost/zf-project/ .
.htaccess in zf-project directory (right near public/, application/, library/ ...):
RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]
.htaccess in public/ directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
And in application/configs/application.ini you set
resources.frontController.baseUrl = "/zf-project/"
Here is my .htaccess which is work perfect:
DirectoryIndex /public/index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^js/(.*)$ public/js/$1 [L]
RewriteRule ^img/(.*)$ public/img/$1 [L]
RewriteRule ^css/(.*)$ public/css/$1 [L]
RewriteRule ^.*$ public/index.php [NC,L]