Symfony2 .htaccess issue - .htaccess

I have a Symfony2 app deployed on EC2 instance in amazon.
I try to rewrite a.htaccess to modify the address:
http://ec2-xxxxxxxxxxx.eu-west-1.compute.amazonaws.com/symfony/web/app.php/mysite
The problem is modify /symfony/web/app.php to show just /mysite
What i need to modify in the .htaccess?
Thanks

Make sure that your VirtualHost setup has correct DocumentRoot. It should point to web directory like this - /var/www/symfony/web

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app_dev.php/$1 [L,QSA]

Related

.htaccess issue in LiteSpeed Web Server

Need help with litespeed web server .htaccess rules.
http://example.com/temp/home.php is existing URL, but now what we need to rewrite is mentioned below:
http://example.com/temp.php?redirect=home.php
And our Existing .htaccess code is also given below.
RewriteEngine on<br/>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
But I don't know the issue, this rewrite still not working and shows 404 error because temp/home.php does not exist.
These rules are working perfectly with Apache server, but not working with Litespeed
For reference:
https://htaccess.madewithlove.be?share=d15d3bca-6974-5682-902a-823c1a63e2b7
Thanks in advance.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
The above code will serve the content of temp.php?redirect=home.php.
As a test I created temp.php in the root directory of a domain, with the content:
<?php
var_dump($_GET);
The result when accessing /temp/home.php is:
array(1) {
["redirect"]=>
string(8) "home.php"
}
This is tested on LiteSpeed Web Server 5.3.4 and 5.3.5.

RewriteRule redirects to domain root

I'm trying to make any image file name that doesn't exists in my server to load default.jpg in it.
This is what I tried on my .htaccess:
RewriteEngine On
RewriteRule ^\w+\.jpg$ /default.jpg
But everytime I access my /randomimagename.jpg the browser redirects me to my domain root.
Any ideas?
Try with:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.jpg$ /default.jpg [NC,L]

Redirecting another domain to an existing drupal installation's subdirectory

I've been trying to solve a problem for the past few hours. I am desperate for help!
I have two domains:
rd1.example.com/drupal
rd2.example.com
I have a drupal installation in rd1.example.com/drupal/
Further, I started creating content on drupal in a url alias: rd1.example.com/drupal/rd2/
What I want to do is used the second website to point to that specific content within my drupal installation:
rd2.example.com -> rd1.example.com/drupal/rd2/
I don't want it to be a redirect but an internal hidden redirect. The user will think that they are on rd2.example.com.
I've switched rd2.example.com to point to the directory where drupal is installed. I've been trying to edit the rewriterules on drupal's .htaccess but with no luck. Any help is greatly appreciated. Here is my rules so far:
#Existing settings
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^rd2\.example\.com [NC]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
#New rules to accomodate for rd2.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^rd2\.example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/rd2%{REQUEST_URI} -f
RewriteRule .* /rd2/$0 [L]
Drupal relies on the server variables to process its request. That means when you internally rewrite to /rd2/$0, drupal doesn't know what to do with that. You'll need to reverse proxy *from the rd2` subdomain instead. So leave drupal the way it is, then on the rd2.example.com document root, add:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^rd2 [NC]
RewriteRule ^(.*)$ http://rd1.example.com/drupal/rd2/$1 [L,P]
This will only work if you have mod_proxy loaded on your server, otherwise nothing will happen. Mod_proxy can only be turned on through your server's config. You could also setup the reverse proxy from the vhost config for the rd2 subdomain:
ProxyPass / http://rd1.example.com/drupal/rd2/
Beside of proxy, you may also consider to use a symbolic link that made by a shell command like so:
ln -s /path/to/rd1 /path/to/drupal/rd2
More details is explained in Multi-site - Sharing the same code base

codeigniter application works on hostgator but not another web host

I have a codeigniter application that is working perfectly on my hostgator hosted domain.
I have configured .htaccess and config.php to remove the index.php from the URL. As mentioned this is working 100%. I now need to move the application from my hostgator server to a local server in South Africa with Afrihost.
the modified htaccess and config file are shown below:
my htaccess file is:
RewriteEngine on
RewriteBase /
# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
# Prevent user access to the CI system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Prevent user access to the CI application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
and my config.php file is:
$config['base_url'] = 'http://logicoportal.co.za';
$config['index_page'] = '';
// let me know if you need to see any other setting
When I try to browse to the domain http://www.logicoportal.co.za I get error This page can't be displayed.
If I browse to my ion auth controller, http://logicoportal.co.za/auth/login I get 404 error The webpage cannot be found.
If I browse to my full codeigniter default path, http://logicoportal.co.za/index.php/auth/login I get error This page can't be displayed
I am assuming it is an htaccess configuration error however I am not sure how to correct this. read many an article with no luck. Alternatively is there another config setting in codeigniter to support this?
I have spoken to the new hosting company, Afrihost and they say they cannot help in this regard.
Any advice / direction would be appreciated.
Thanks as always.
Working Solution:
htaccess file to remove index.php on shared hosting server
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./index.php [L]
Try removing the ? in:
RewriteRule ^(.*)$ /index.php?/$1
So it's:
RewriteRule ^(.*)$ /index.php/$1

Codeigniter mod rewrite in CentOS

I am trying to set up my project (built in Codeigniter) in Apache/2.0.52 (CentOS) Server.
Everything works perfectly on my local XAMPP server but on the live server, when i try to access pages like myproject.com/agents, it shows
'The requested URL /home/virtual/site777/somefolder/var/www/html/index.php/agents was not found on this server.'
The rewrite rule that I've got at the moment:
RewriteEngine on
RewriteCond $1 !^(assets|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have following settings in my application/config.php file
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I would really appreciate if someone could help me.
Thank you!
On my CentOS I only have this:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
But my site resides in /var/www/html. I am by no means an expert on Apache, but perhaps you need to set the
RewriteBase /home/virtual/site777/somefolder/var/www/html/
As well
Thank you all for viewing and answering my question.
I was able to solve my problem using RewriteBase in htaccess file.
you have to enable url rewriting module of apache.

Resources