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>
Related
I have been trying to shorten URLs with apache .htaccess file, and currently I have this code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*)$ show.php?page=$1 [NC, QSA, L]
AllowOverride All
With this code, for example https://example.com/welcome should be redirected to https://example.com/show.php?page=welcome, but it is not. When I run sudo a2enmod rewrite, I get the following:
Module rewrite already enabled
I also tried to run service apache2 restart. How can I solve it?
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 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?
I've got a CMS installed in a sub-directory of my webspace and I'm having a little trouble figuring out how to configure the htaccess file.
mysite.com contains a splash page that should stay there for now. The idea is that mysite.com/dev should open the index page of the CMS. I suppose I could go with a subdomain but I'll have to research what to do in this case. Either way all of this is just temporary so whatever works is good.
You can see from the below code I've been messing around and I've commented out a lot of stuff. (I've also not bothered to copy more that I think is probably nonsense.)
#Display PHP Errors
php_flag display_errors Off
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^www\.mysite\.com\dev [NC]
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dev/index.php?q=$1 [L,QSA]
I should note that I'm with a hosting company any my root path is something like
/content/hosting/l/u/mysite.com/web
I've tried to add this (and truncated versions) to my htaccess file but without success.
If dev is your CMS and you want site/dev to open index.php in dev, your htaccess file for dev only needs this line:
DirectoryIndex index.php
Solved:
unfortunately, the solution is not a satisfying one. This morning, when trying #Wige's Suggestion, I found, to my suprise, that the Expected values WERE infact sent to the page as a GET query. Apparently, 1&1 (who I know have been making changes to their environment this last couple weeks), did something behind the scenes which magically fixed my problem, and now all of my previously unworking code is working as originally expected.
New info: The Apache version of the production server is 1.3.34 vs 2.2.21 on my localhost.
I'm having trouble figuring out why my RewriteRule is not working properly in production.
RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]
In my local testing environment (localhost/mysite/page/pretty-url/{...}) it works fine, but on mysite.com/page/pretty-url/{...} it doesn't work properly. It loads page.php as expected but apparently the ?query=$1 piece is ignored ($_GET is empty)
I imagine that the problem is somehow related to the server configuration. I'm on a 1&1 shared hosting account with no httpd.conf access.
What that RewriteRule does (or should do):
I want urls like
*example.com/page/pretty-url/{{info_for_dynamic_content}}
to be rewritten to
*/page.php?query={{info_for_dynamic_content}}
So I can access info_for_dynamic_content
within php as $_GET['query']
The full .htaccess file for reference:
AddHandler x-mapp-php6 .php
DirectoryIndex index.php
ErrorDocument 404 /index.php
Options +FollowSymLinks
# per #Jacques Chester's suggestion
Options -MultiViews
RewriteEngine on
RewriteBase /
# the rule in question
RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f
RewriteRule (.*) /index.php [L]
Most likely, your host is storing the variables somewhere else. I would add a call to phpinfo(); into your script and go through the environment variables there to see if you can find the values that should have been in get.
Seems to be connected to 1&1's hosting environment.
See this question, in particular, this answer.
Basically it appears that 1&1 enable "MultiViews". By adding
Options -MultiViews
You disable that setting for your website and according to various reports, this resolves the issue.
I struggled with RewriteRule issues on a 1&1 / 1and1 / IONOS shared server for WEEKS and eventually I found the perfect setup for a 1 and 1 shared server, start your .htaccess file like this
Options -MultiViews
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
I hope this helps someone as 1&1 are useless when it comes to htaccess support