Aug 10, 2010

Rewrite symfony URL

Setting the virtual host:

<VirtualHost *:80>
ServerName admin.my-app.com
DirectoryIndex backend.php
DocumentRoot "/path/to/the/web/directory"
<Directory "/path/to/the/web/directory">
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
Alias /sf /path/to/the/symfony/data/web/sf
<Directory "/path/to/the/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>


Setting the .htaccess

Options +FollowSymLinks +ExecCGI



RewriteEngine On

## uncomment the following line, if you are having trouble
## getting no_script_name to work
RewriteBase /

## we skip all files with .something
##RewriteCond %{REQUEST_URI} \..+$
##RewriteCond %{REQUEST_URI} !\.html$
##RewriteRule .* - [L]

## we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

## no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]

## Just search in the Net
## The admin subdomain returns to the backend
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{HTTP_HOST} ^admin\.my-app\..*
#RewriteRule ^(.*)$ backend.php [QSA,L]

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{HTTP_HOST} ^admin\.my-app\..*
#RewriteRule ^(.*)$ index.php [QSA,L]



Try to access like


http://host.com/module/action

The common to access is

http://host.com/index.php/module/action


Reference URL

No comments: