.htaccess Wordpress Symfony - apache

I have a Symfony 1.4 project. With standard .htaccess:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
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]
</IfModule>
I just want to have in my web symfony folder a Wordpress setup (in fact many, with different languages):
-web (folder)
index.php
frontend.php
-blogwordpress
-fr
index.php
-en
index.php
My question is: what should I write on .htaccess file shown before to allow a request like:
http://127.0.0.1/blogwordpress/fr
to be catched up by the Wordpress index.php, and not by the Symfony frontend ?
Of course when I type this url 404 appears on my Symfony:
404 | Not Found | sfError404Exception
Action "blogwordpress/fr" does not exist.
Thanks in advance

Add this right after the RewriteEngine On statement;
RewriteCond %{REQUEST_URI} !^/?wordpress
In layman's terms;
only apply the following rules if the request does not begin with wordpress

Related

how to redirect to sub directory in htaccess without direct access to it

I already asked this question but no answers.
I develop new forum So I put some files like index, login, signup and etc... in sub directory called webroot and i want to redirect all requests to webroot without direct access to it for example:
localhost/myforum [root project files] should access with no problems but
localhost/myforum/webroot redirect to 404
myforum/.htaccess
DirectoryIndex index.php
# No directory listings
IndexIgnore *
<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment the following line if your webserver's URL is not directly related to physical file paths.
# Also uncomment it if you are on 1&1 hosting
#RewriteBase /
# Comment the following line if you have not a .well-known directory in the root folder.
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
myforum/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Have myforum/webroot/.htaccess as this code:
<IfModule mod_rewrite.c>
RewriteEngine On
# return 404 if accessed directly
RewriteCond %{THE_REQUEST} /webroot/ [NC]
RewriteRule ^ - [L,R=404]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

Getting 404 error when viewing CakePHP 3 app on 1and1

When I attempt to hit my site which is at mydomain.com/subfolder, I get a 404 (from Apache).
/subfolder/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/subfolder/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
To confirm that mod_rewrite works, I added this in the /subfolder/.htaccess file which promptly redirected:
Redirect 301 / http://other-domain-owned.com/
So, .htaccess are live and mod_rewrite works.
On my development environment, I was able to make the site work in the same /subfolder by symply enabling .htaccess files for that folder via a Directory directive.
Some tutorials say to add RewriteBase / but this didn't help.
Instead of RewriteBase, you can also use an absolute path. Additionally, the first two rules can be simplified to one
RewritRule ^(.*)$ /subfolder/webroot/$1 [L]
Similar the second part
RewriteRule ^ /subfolder/webroot/index.php [L]
Finally, Redirect and RewriteRule are from different modules. So, if one of the directives is working, this is no proof for the other one working too.

Laravel on Plesk-Server - Only accessible by calling /public

When setting up a fresh Laravel installation, we have to run it using domain.com/public instead of domain.com.
I googled after this problem and I saw that this could be because of mod_rewrite not being enabled. However, we are running Plesk on our server and their documentation at http://download1.parallels.com/Plesk/PP12/12.0/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=74206.htm says:
The mod_rewrite module is enabled by default in Apache that comes with Plesk for Linux. To make use of the functionality, you will need to create an .htaccess file containing the desired rewrite rules - refer to the Apache documentation for more information.
Laravel is working fine, if I move the contents of public in the main folder, and the rest in a /laravel folder (simply have to adopt the main index.php file).
However I would like to keep the original file structure.
Any tips?
Just use .htaccess to redirect from / to /public. Maybe similar to this
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
You need two .htaccess files. One inside the Laravel Project and the other one inside your domain.com
Laravel Project (/var/www/vhosts/domain.com/public/.htaccess)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php?$1 [L,QSA]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
main domain (/var/www/vhosts/domain.com/.htaccess)
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Mod rewrite to remove subdirectory and file extension without breaking DirectoryIndex

I have all site pages in a subdirectory like this...
http://www.example.com/pages/myfile.php
I want the URL to look like this...
http://www.example.com/myfile
Where both the subdirectory called pages and the .php file extension are removed from the URL.
My latest (partial) attempt...
Options All -Indexes +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/pages%{REQUEST_URI}\.php -f [OR]
RewriteCond %{DOCUMENT_ROOT}/pages%{REQUEST_URI} -d
RewriteRule ^(.*)$ /pages/$1.php [NC,L]
However, this totally breaks DirectoryIndex. When I go to http://www.example.com/ or http://www.example.com/foo/, I get a 404 error instead of defaulting to index.php as defined by DirectoryIndex.
Apparently, it treats everything as a file name instead of recognizing the lack of a file name (directory) and attempting to use index.php.
I tried incorporating this solution into mine, it fixed the DirectoryIndex issue, but it broke everything else.
Is there a solution? Please include a detailed explanation within your answer so I can learn where/how I was going wrong.
Try this in root .htaccess:
Options All -Indexes +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
# add a trailing slash if pages/<uri> is a directory
RewriteCond %{DOCUMENT_ROOT}/pages/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,R=302]
RewriteRule ^/?$ pages/index.php [L]
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# if corresponding .php file exists in pages/ directory
RewriteCond %{DOCUMENT_ROOT}/pages/$1\.php -f
RewriteRule ^(.+?)/?$ pages/$1.php [L]
# route all requests to pages/
RewriteRule ^((?!pages/).*)$ pages/$1 [L,NC]

How can I remove "index.php" from my links?

Normally I access a page like this: http://localhost/codeigniter/index.php/auth/login
However I want to be able to access to the page like this : http://localhost/codeigniter/auth/login
I have no information about http.conf and .htaccess configurations.
I have set $config['index_page'] = ''; in codeigniter/application/config/config.php
my http.conf file is at its default except uncommentnig "LoadModule rewrite_module modules/mod_rewrite.so"
I inspected many proposed .htaccess files but I could not understand the logic behind the rewriting rules.
Here is the most successful .htaccess content for me. It is located at /www/CodeIgniter/ .
(by the most successful I mean that this is the only one that gives 404 error created by the CodeIgniter not by the server.)
RewriteOptions Inherit
Options -Indexes
Options +FollowSymLinks
RewriteBase /CodeIgniter/
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# activate URL rewriting
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(images|assets|uploads|captcha)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt)
# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
I hate requesting direct solutions however unfortunately, it is my last resort :/
Can you give me a right solution to my problem?
It's my repeat answer:
Codeigniter issues with paths in localhost (XAMPP)
please create .htaccess file in project folder and write:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
You don't need to define in base_url in config file:
$config['base_url'] = ''; // blank it.
put this on your htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
make sure the rewrite module is enabled on your server
This is the simplest one i found which works for me :-
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]