Silex rewrite, one.com - apache

I am using this apache rewrite, when i am on my local machine.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /skoleskak/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
But after i uploaded it, to my host i get server error. They told me they dont support Options, but i can't get it working without that.
I am trying to route my Silex installation, so its /web/stats/ instead of web/index.php/stats.
I found this example for Codeigniter http://www.chrishjorth.com/blog/one-com-codeigniter-htaccess-rewrite-rules/
Anyone know how to make it work with Silex?

Same problem at some hosters. If your server has installed Apache >= 2.2.16 you can use the FallbackResource command:
FallbackResource /index.php
in your .htaccess instead of
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /skoleskak/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
See also Apache’s fallbackresource: your new .htaccess command for more information.

Related

Url-rewriting using .htaccess is not working

I would like my url which is: http://localhost/slide-form/ad_posted.php?title=Cow%20Buffalo%20Gopal-1426356570
to look like : http://localhost/slide-form/ad_posted/title/Cow%20Buffalo%20Gopal-1426356570/
The below is the rule i have added in my htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ad_posted/title/(.*)/ ad_posted.php?title=$1
RewriteRule ad_posted/title/(.*) ad_posted.php?title=$1
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.html
</IfModule>
But I see no changes in my url. Any help is much appreciated. Thanks
Have this code in /slide-form/.htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /slide-form/
RewriteCond %{THE_REQUEST} /ad_posted\.php\?title=([^\s&]+) [NC]
RewriteRule ^ ad_posted/%1? [R=302,L,NE]
RewriteRule ^ad_posted/title/(.+)/?$ ad_posted.php?title=$1 [L,QSA]
There are two things need to attention:
Make sure you apache or other web server is already opened rewrite
module.
Check your configuration settings and ensure the directory where
.htaccess file located have the overwrite permission.
Like following settings:

Object not found! in xampp

I'm using creo's module system and laravel 4. mod_rewrite is enabled and I have a .htaccess I'm also using XAMPP. The weird thing is, if I use MAMP then it works fine but if I use XAMPP that is when I get the Object Not Found error. I would like to use XAMPP because it is much more easier to create a virtual host with it then it is with MAMP.
In my url I have
http://localhost/test-modules/index.php/admin/content
but I need it to be
http://localhost/test-modules/admin/content
here is my .htaccess
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Disallow access to following directories
#RewriteRule ^vendor($|/|/.*|./*) – [L,R=404]
#RewriteRule ^app($|/|/*|/.*) – [L,R=404]
</IfModule>
Do yourself a favor and don't use either MAMP or XAMP. Use homestead.
http://laravel.com/docs/4.2/homestead
To give you some guides:
https://laracasts.com/lessons/say-hello-to-laravel-homestead-two

Cake 2.+ on shared hosting - 404 error

Since 2 days I have been trying to get my cake app working (using German 1&1 hosting). The desired address is: http://www.bzalewski.de/k/front. If you open it, you can see, it's there but without images and css. Also this: http://www.bzalewski.de/k/front/art/discover doesn't work (but it does locally with XAMPP. There is no routing, just ArtController --> public function discover()).
I followed the instructions from this article: http://bakery.cakephp.org/articles/tim_m/2007/09/20/500-errors-with-1and1-hosting-apache-1-x
My three .htaccess look like this:
./.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^$ /k/front/app/webroot/ [L]
RewriteRule (.*) k/front/app/webroot/$1 [L]
</IfModule>
./app/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^$ /k/front/app/webroot/ [L]
RewriteRule (.*) /k/front/app/webroot/$1 [L]
</IfModule>
.app/webroot/.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /k/front/app/webroot/index.php?url=$1 [QSA,L]
</IfModule>
I would appreciate any help to:
make controllers work (art/discover working)
make images and other stuff in the webroot directory work
Just to mention it: my local XAMPP installation works with standard .htaccess files without any problems.
Try adding this line in the root .htaccess (the htaccess in /k/front/ folder) after RewriteEngine On:
RewriteBase /k/front/
Edit : I did not see that you put /k/front/ everywhere in the htaccess
Then add RewriteBase / with you version of the htaccess
OR add RewriteBase /k/front/ with the default htaccess (without /k/front/ in the RewriteRules )

Having trouble with mod_rewrite on my Laravel app

Currently, I can only access links on my Laravel project if they are in the form of domain.com/index.php/somepage. I want to be able to be able to get access with a URL like domain.com/somepage. On my local Windows machine it is working fine. My server is on Ubuntu and running Apache 2.4.6 and the rewrite module was enabled via a2enmod rewrite. My .htaccess is the default one that ships with Laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I've also tried the alternate in the Laravel docs both with and without the <IfModule>:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I realize this has been asked before but I still can seem to get it working with other examples that I've seen. I'm guessing it must be some Apache configuration that I don't have set.
Did you make sure that allowoverides all was in your httpd config?
That sounds like your issue.

Beginner Apache URL Rewrite Question

I'm just trying to figure out if I'm on the right path - additional details on rewriting the URL in my example would be appreciated.
I have installed a CMS program and would simply like that www.example.com be pointed to www.example.com/cms. I just want to know if URL rewriting through apache is the best way to accomplish this?
Thank you.
Just redirecting http://example.com/ to http://example.com/cms/:
<IfModule mod_rewrite.c>
RewriteEngine On
RewritRule ^/?$ /cms/
</IfModule>
Redirecting all urls which otherwise would've 404d to start with /cms/:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cms/$1 [L]
</IfModule>
Redirecting all urls to /cms/:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /cms/$1 [L]
<Directory /var/www/html/cms/> #change this to the correct path
RewriteEngine Off
</Directory>
</IfModule>
That's definitely the approach I would take. I'm going to assume you're using Apache, though this can easily be done with IIS as well. You'll need to edit your .htaccess file in the root directory to do this using mod_rewrite.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ /cms/$1 [L]
</IfModule>
This should work for what you're after. Change "cms" to whatever directory you want to rewrite to.