I have a website written with kohana. I want to test it if its working with ssl. I have ssl module installed (ubuntu default ssl configuration). The problem is: all my websites using kohana on localhost (apache) not working with https:// (only main pages are working for example: "https:localhost/kohanasite" is working, but if i give controller and action it is not working, but if i ad index.php before controler and action it is working again). Other websites (not written with kohana) are working properly. My htaccess is as follows:
RewriteEngine On
RewriteBase /sitename/
Order Deny,Allow
Deny From All
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
php_value allow_url_fopen on
php_value allow_url_include 1
Plese help.
You need to create a new Apache configuration for the https sites too. Enable the module is not enough. How do I allow HTTPS for Apache on localhost?
Related
I created a new Symfony project, without using the installer, according to the instructions here: http://symfony.com/doc/current/book/installation.html#creating-symfony-applications-without-the-installer.
I accepted all the defaults, including the demo bundle, AcmeWebBundle.
I configured an Apache virtual host doc-rooted at the new project and restarted the web server. I would like to access the application via "http://virtualhost/" (ie, without explicitly calling the front-end controller app.php or app_dev.php).
Installed with the project was a .htaccess file that sets the DirectoryIndex to app.php. I would like to use the developer environment for development, but (long story short) it seems the only way to do this is by manually editing the .htaccess file - both the DirectoryIndex setting, plus a few mod_rewrite directives.
Is there a simpler way to switch between environments/controllers without having to edit the .htaccess file? For bonus points, I had to figure this out by trial and error - was this explained in the documentation someplace that I missed?
Thanks, and have a nice day.
You need this one:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_NAME} \.dev$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
If you use host that ends on .dev you will work with dev-environment.
For example you can use virtualhost as prod-env host and virtualhost.dev as dev-env host.
I'm migrating a system from a Windows server to a Ubuntu server. Both are using Apache2. The rule in question is as follows:
Options +FollowSymlinks
RewriteEngine On
<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/.*_[pP]([0-9]\d*)\.cfm$ $1/index.cfm?productID=$2&%1 [L]
RewriteCond %{REQUEST_URI} ^/sitemap.xml [NC]
RewriteRule (.*) /includes/site_map/xml_site_map.cfm [L]
The goal is to rewrite a URL like this one: http://example.com/html/products/sample_product_201011_p5974.cfm into one like this: http://example.com/html/products/index.cfm?productID=5974 (the first rule above).
It works correctly on the Windows server and if I copy the exact .htaccess above into an online htaccess tester. Also, I can successfully use .htaccess to do domain redirects as well as the second rule above.
Is there an extra apache module I'm missing? I've got alias, rewrite, and speling enabled (among others that aren't relevant).
I have frusted doing all things given on web for htaccess get working on ubuntu. But I could not do it. Actually I want to run my CodeIgniter app on LAMP, its not production server. so in www directory, there could be multiple folders e.g.
www/punepchub
I access url localhost/punepchub/support/ , it gives 404 error
I want to redirect above link to localhost/punepchub/index.php/support/
using htaccess, following are the contents of htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Where as above mentioned htaccess works perfect on wamp as well as lamp given by godaddy hosting, but it is not working on LAMP server setup on my local ubuntu 12.04 desktop machine
I think apache is not accessing the htaccess file.
I tried following but It didn't worked
I have installed lamp using tasksel
Enabled Rewrite module using command: sudo a2enmod rewrite
It displays the module in the list given by command: sudo apache2ctl -M
Changed etc/apache2/sites-available/default file with AllowOverride All, Also I did same in etc/apache2/sites-enabled/000-default
I have 777 permissions for project folder and files
Also I am confused about Is there any need to create virtual hosts, as this is not production server.
Please help me I really don't know how resolve this issue now.
In advance many thanks
Try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /punepchub/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /punepchub/index.php [L]
</IfModule>
I have two questions regarding pointing subdomains to a directory:
Currently I run local, but I can run my site on a fake domain i have set up (with hosts file), its called mysite.com. How can i (by server settings?) do so All subdomains will point to / ? Example anders.mysite.com should show mysite.com and asdassdd.mysite.com also.
Maybe 1. is not necessary, but how do i by htaccess point anders.mysite.com to mysite.com/anders ? Important notice is that should not redirect.
Why i thought of 1. is because I do not want to specify anywhere in the htaccess or any apache/domain setting, what the subdomain are, since this will be dynamic (created by logged in users in my webapplication)
Currently the users can use mysite.com/anders/ which is a URI they have created, and not a real directory. In the Kohana bootstrap I am then grabbing the URI and showing the relevant user page.
I am using Kohana MVC framework and have this in my htaccess:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Any help appreciated!
For 1, in your vhost just add a ServerAlias:
ServerAlias *.mysite.com
Then any subdomain (www included) will get pointed to the same document root.
If you want to put subdomains in their own directory (and since you have access to server config), you can use mod_vhost_alias and the VirtualDocumentRoot directive:
VirtualDocumentRoot /path/to/your/htdocs/%1
So if you request blah.mysite.com, you'll end up in /path/to/your/htdocs/blah as the doc root.
If it's a matter of you needing directory names of non-existent directories in the URI so that Kohana can route them, you'll need to make sure you have mod_proxy loaded:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteCond %{REQUEST_URI} !^/%1/
RewriteRule ^(.*)$ /%1/$1 [L,P]
To proxy the request back to Kohana with the right URI.
how do i by htaccess point anders.mysite.com to mysite.com/anders ? Important notice is that should not redirect.
You can use this rule:
RewriteCond %{HTTP_HOST}:%{REQUEST_URI} ^([^.]+)\.[^:]+:(?!/\1/).*$
RewriteRule ^ /%1%{REQUEST_URI} [L]
I'm trying to add some secure pages to a site. The links in the site all use the current protocol (i.e. are protocol independent, paths start with //).
I need the paths /info/season-tickets/* and /ticketcontroller/* to use https, and all others using http.
I've tried building rules to do the following (ignoring the ticketcontroller part for now):
If Port==80 and Path==/info/season-tickets/, rewrite with https
If Port==443 and Path!=/info/season-tickets/, rewrite with http
However, when I access /info/season-tickets/, rather than redirecting to the https version, I get example.com/index.php/info/season-tickets
The .htaccess is below - my attempts are below # Force https on certain pages and # Force http everywhere else, and the other bits are from the Kohana framework
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Force https on certain pages
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/info/season-tickets/?
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
# Force http everywhere else
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} !^/info/season-tickets/?
RewriteRule ^(.*)$ http://www.example.com/$1 [R,L]
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
I tried re-ordering the rules to see if that fixed it, but it didn't.
Any ideas why this isn't working (http://htaccess.madewithlove.be/ shows that it should work)...
Thanks!
I've solved this issue, not with htaccess, but in the index.php file (all requests go through this).
By default, I assume port 80. Then, if $_SERVER['REQUEST_URI'] is in an array of secure paths, I switch the variable to 443.
Then, if $required_port != $_SERVER['SERVER_PORT'], I redirect and exit().